2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-03 15:55:40 +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:
Todd C. Miller
2021-03-01 07:22:57 -07:00
parent 79dbf9f17e
commit 4a28b5d587

View File

@@ -737,6 +737,12 @@ 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)
{ {
switch (pass) {
case PASS_CHECK_NOT_FOUND:
return NOT_FOUND;
case PASS_CHECK_NOT_FOUND_DOT:
return NOT_FOUND_DOT;
default:
if (infile[0] == '/') { if (infile[0] == '/') {
*outfile = strdup(infile); *outfile = strdup(infile);
} else { } else {
@@ -745,13 +751,6 @@ find_path(const char *infile, char **outfile, struct stat *sbp,
} }
if (*outfile == NULL) if (*outfile == NULL)
return NOT_FOUND_ERROR; return NOT_FOUND_ERROR;
switch (pass) {
case PASS_CHECK_NOT_FOUND:
return NOT_FOUND;
case PASS_CHECK_NOT_FOUND_DOT:
return NOT_FOUND_DOT;
default:
return FOUND; return FOUND;
} }
} }