From: Matthias Bolte Date: Thu, 10 Jun 2010 19:52:33 +0000 (+0200) Subject: Check getenv("PATH") for NULL in virFindFileInPath X-Git-Tag: v0.8.2~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc1da688c0632130c036f946cad427737105dd0c;p=thirdparty%2Flibvirt.git Check getenv("PATH") for NULL in virFindFileInPath Otherwise this will segfault if PATH is not defined. Reported by Emre Erenoglu --- diff --git a/src/util/util.c b/src/util/util.c index 34cfc212e8..445fd4e7d4 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1213,6 +1213,7 @@ int virFileResolveLink(const char *linkpath, */ char *virFindFileInPath(const char *file) { + char *path; char pathenv[PATH_MAX]; char *penv = pathenv; char *pathseg; @@ -1232,7 +1233,9 @@ char *virFindFileInPath(const char *file) } /* copy PATH env so we can tweak it */ - if (virStrcpyStatic(pathenv, getenv("PATH")) == NULL) + path = getenv("PATH"); + + if (path == NULL || virStrcpyStatic(pathenv, path) == NULL) return NULL; /* for each path segment, append the file to search for and test for