r4613 - trunk/src/target/opkg/libopkg
tick at docs.openmoko.org
tick at docs.openmoko.org
Wed Aug 27 17:32:21 CEST 2008
Author: tick
Date: 2008-08-27 17:32:20 +0200 (Wed, 27 Aug 2008)
New Revision: 4613
Modified:
trunk/src/target/opkg/libopkg/opkg_cmd.c
Log:
[opkg] fix opkg crashes if PATH is unset
Thanks for chgros
Modified: trunk/src/target/opkg/libopkg/opkg_cmd.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-08-26 08:31:26 UTC (rev 4612)
+++ trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-08-27 15:32:20 UTC (rev 4613)
@@ -312,12 +312,19 @@
static opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf)
{
opkg_intercept_t ctx;
+ char *oldpath;
char *newpath;
int gen;
ctx = malloc (sizeof (*ctx));
- ctx->oldpath = strdup (getenv ("PATH"));
+ oldpath = getenv ("PATH");
+ if (oldpath) {
+ ctx->oldpath = strdup (oldpath);
+ } else {
+ ctx->oldpath = 0;
+ }
+
sprintf_alloc (&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath);
setenv ("PATH", newpath, 1);
free (newpath);
@@ -344,8 +351,12 @@
DIR *dir;
int err = 0;
- setenv ("PATH", ctx->oldpath, 1);
- free (ctx->oldpath);
+ if (ctx->oldpath) {
+ setenv ("PATH", ctx->oldpath, 1);
+ free (ctx->oldpath);
+ } else {
+ unsetenv("PATH");
+ }
dir = opendir (ctx->statedir);
if (dir) {
More information about the commitlog
mailing list