提交 fc1da688 编写于 作者: M Matthias Bolte

Check getenv("PATH") for NULL in virFindFileInPath

Otherwise this will segfault if PATH is not defined.

Reported by Emre Erenoglu
上级 b28a068b
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册