mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
Check getenv("PATH") for NULL in virFindFileInPath
Otherwise this will segfault if PATH is not defined. Reported by Emre Erenoglu
This commit is contained in:
parent
b28a068b43
commit
fc1da688c0
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user