mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-03 07:45:47 +00:00
In find_path() stub only make a copy in outfile if returning FOUND.
Fixed a recently-introduced memory leak in the fuzzer.
This commit is contained in:
@@ -737,21 +737,20 @@ find_path(const char *infile, char **outfile, struct stat *sbp,
|
|||||||
const char *path, const char *runchroot, int ignore_dot,
|
const char *path, const char *runchroot, int ignore_dot,
|
||||||
char * const *allowlist)
|
char * const *allowlist)
|
||||||
{
|
{
|
||||||
if (infile[0] == '/') {
|
|
||||||
*outfile = strdup(infile);
|
|
||||||
} else {
|
|
||||||
if (asprintf(outfile, "/usr/bin/%s", infile) == -1)
|
|
||||||
*outfile = NULL;
|
|
||||||
}
|
|
||||||
if (*outfile == NULL)
|
|
||||||
return NOT_FOUND_ERROR;
|
|
||||||
|
|
||||||
switch (pass) {
|
switch (pass) {
|
||||||
case PASS_CHECK_NOT_FOUND:
|
case PASS_CHECK_NOT_FOUND:
|
||||||
return NOT_FOUND;
|
return NOT_FOUND;
|
||||||
case PASS_CHECK_NOT_FOUND_DOT:
|
case PASS_CHECK_NOT_FOUND_DOT:
|
||||||
return NOT_FOUND_DOT;
|
return NOT_FOUND_DOT;
|
||||||
default:
|
default:
|
||||||
|
if (infile[0] == '/') {
|
||||||
|
*outfile = strdup(infile);
|
||||||
|
} else {
|
||||||
|
if (asprintf(outfile, "/usr/bin/%s", infile) == -1)
|
||||||
|
*outfile = NULL;
|
||||||
|
}
|
||||||
|
if (*outfile == NULL)
|
||||||
|
return NOT_FOUND_ERROR;
|
||||||
return FOUND;
|
return FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user