if (strlen(infile) >= PATH_MAX) {
errno = ENAMETOOLONG;
- fatal("%s", infile);
+ debug_return_int(NOT_FOUND_ERROR);
}
/*
*/
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;
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)
rval = find_path(NewArgv[0], &user_cmnd, user_stat, path,
def_ignore_dot);
restore_perms();
- if (rval != FOUND) {
+ if (rval == NOT_FOUND) {
/* Failed as root, try as invoking user. */
set_perms(PERM_USER);
rval = find_path(NewArgv[0], &user_cmnd, user_stat, path,
def_ignore_dot);
restore_perms();
}
+ if (rval == NOT_FOUND_ERROR) {
+ if (errno == ENAMETOOLONG)
+ audit_failure(NewArgv, N_("command too long"));
+ log_fatal(NO_MAIL|USE_ERRNO, NewArgv[0]);
+ }
}
/* set user_args */
}
}
}
- if (strlen(user_cmnd) >= PATH_MAX) {
- audit_failure(NewArgv, N_("command too long"));
- errno = ENAMETOOLONG;
- fatal("%s", user_cmnd);
- }
if ((user_base = strrchr(user_cmnd, '/')) != NULL)
user_base++;
/*
* find_path()/set_cmnd() return values
*/
-#define FOUND 0
-#define NOT_FOUND 1
+#define FOUND 0
+#define NOT_FOUND 1
#define NOT_FOUND_DOT 2
+#define NOT_FOUND_ERROR 3
/*
* Various modes sudo can be in (based on arguments) in hex