mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +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 *virFindFileInPath(const char *file)
|
||||||
{
|
{
|
||||||
|
char *path;
|
||||||
char pathenv[PATH_MAX];
|
char pathenv[PATH_MAX];
|
||||||
char *penv = pathenv;
|
char *penv = pathenv;
|
||||||
char *pathseg;
|
char *pathseg;
|
||||||
@ -1232,7 +1233,9 @@ char *virFindFileInPath(const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy PATH env so we can tweak it */
|
/* 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;
|
return NULL;
|
||||||
|
|
||||||
/* for each path segment, append the file to search for and test for
|
/* for each path segment, append the file to search for and test for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user