In find_path(), return NOT_FOUND_ERROR instead of calling fatal()

if the path is too long.  Remove an extraneous check against PATH_MAX
in set_cmnd() since find_path() already contains such a check.
This commit is contained in:
Todd C. Miller
2014-03-26 14:15:15 -06:00
parent 4848b5691d
commit 639ac92e6d
3 changed files with 13 additions and 11 deletions

View File

@@ -66,7 +66,7 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
if (strlen(infile) >= PATH_MAX) {
errno = ENAMETOOLONG;
fatal("%s", infile);
debug_return_int(NOT_FOUND_ERROR);
}
/*
@@ -106,8 +106,9 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
*/
len = snprintf(command, sizeof(command), "%s/%s", path, infile);
if (len <= 0 || (size_t)len >= sizeof(command)) {
efree(origpath);
errno = ENAMETOOLONG;
fatal("%s", infile);
debug_return_int(NOT_FOUND_ERROR);
}
if ((found = sudo_goodpath(command, sbp)))
break;
@@ -124,7 +125,7 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
len = snprintf(command, sizeof(command), "./%s", infile);
if (len <= 0 || (size_t)len >= sizeof(command)) {
errno = ENAMETOOLONG;
fatal("%s", infile);
debug_return_int(NOT_FOUND_ERROR);
}
found = sudo_goodpath(command, sbp);
if (found && ignore_dot)