summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-08-13 02:16:40 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-08-13 02:16:40 +0000
commitf029e36352c6a0bf991f0a6100d68b28f0b31dc9 (patch)
treebbac4ef550008fc69382e3a89aa74fb9fbd1356a
parentFix compilation warnings (bug #280373). (diff)
downloadeselect-python-f029e36352c6a0bf991f0a6100d68b28f0b31dc9.tar.gz
eselect-python-f029e36352c6a0bf991f0a6100d68b28f0b31dc9.tar.bz2
eselect-python-f029e36352c6a0bf991f0a6100d68b28f0b31dc9.zip
Fix segmentation fault when PATH isn't set (bug #280780).
-rw-r--r--python.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/python.c b/python.c
index 58d009f..9704400 100644
--- a/python.c
+++ b/python.c
@@ -33,7 +33,15 @@ const char* find_path(const char* exe)
{
return strndup(exe, last_slash - exe);
}
- char* path = strdup(getenv("PATH"));
+ const char* PATH = getenv("PATH");
+ if (! PATH)
+ {
+ /* If PATH is unset, then it defaults to ":/bin:/usr/bin", per
+ * execvp(3).
+ */
+ PATH = ":/bin:/usr/bin";
+ }
+ char* path = strdup(PATH);
char* state = NULL;
const char* token = strtok_r(path, ":", &state);
while (token)