projects
/
oweals
/
opkg-lede.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[opkg] fix opkg crashes if PATH is unset
[oweals/opkg-lede.git]
/
libopkg
/
opkg_cmd.c
diff --git
a/libopkg/opkg_cmd.c
b/libopkg/opkg_cmd.c
index fcf74f6910026b4930e82a272cfbbd1ebdad0a85..2fe74e9d1394ea17b9a7394b6131651cbe301cec 100644
(file)
--- a/
libopkg/opkg_cmd.c
+++ b/
libopkg/opkg_cmd.c
@@
-312,11
+312,18
@@
typedef struct opkg_intercept *opkg_intercept_t;
static opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf)
{
opkg_intercept_t ctx;
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));
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);
sprintf_alloc (&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath);
setenv ("PATH", newpath, 1);
@@
-344,8
+351,12
@@
static int opkg_finalize_intercepts(opkg_intercept_t ctx)
DIR *dir;
int err = 0;
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) {
dir = opendir (ctx->statedir);
if (dir) {