Commit ff2e5dd7 authored by Emmanuel Thomé's avatar Emmanuel Thomé

protect path_resolve in case it overwrites $PATH

parent 57a5fedb
......@@ -163,6 +163,7 @@ int set_antebuffer_path (const char *executable_filename, const char *path_anteb
return 1;
}
fprintf(stderr, "No antebuffer configured\n");
*antebuffer='\0'; /* in case path_resolve leaves crap around */
return 0;
}
......
......@@ -258,6 +258,8 @@ char * path_resolve(const char * progname, char * resolved)
char * path = getenv("PATH");
if (!path) return 0;
char * next_path;
char * path0 = strdup(path);
path = path0;
for( ; *path ; path = next_path) {
next_path = strchr(path, ':');
if (next_path) {
......@@ -271,9 +273,12 @@ char * path_resolve(const char * progname, char * resolved)
#else
snprintf(dummy2, PATH_MAX, "%s/%s", path, progname);
#endif
if (realpath(dummy2, resolved))
if (realpath(dummy2, resolved)) {
free(path0);
return resolved;
}
}
free(path0);
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment