Make sudo_goodpath() return value bolean

This commit is contained in:
Todd C. Miller
2011-11-13 12:11:00 -05:00
parent 5c29710f35
commit f3ae31185b
3 changed files with 19 additions and 25 deletions

View File

@@ -60,8 +60,8 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
static char command[PATH_MAX]; /* qualified filename */
char *n; /* for traversing path */
char *origpath; /* so we can free path later */
char *result = NULL; /* result of path/file lookup */
int checkdot = 0; /* check current dir? */
int found = FALSE; /* did we find the command? */
int checkdot = FALSE; /* check current dir? */
int len; /* length parameter */
debug_decl(find_path, SUDO_DEBUG_UTIL)
@@ -106,7 +106,7 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
len = snprintf(command, sizeof(command), "%s/%s", path, infile);
if (len <= 0 || len >= sizeof(command))
errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
if ((result = sudo_goodpath(command, sbp)))
if ((found = sudo_goodpath(command, sbp)))
break;
path = n + 1;
@@ -117,17 +117,17 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
/*
* Check current dir if dot was in the PATH
*/
if (!result && checkdot) {
if (!found && checkdot) {
len = snprintf(command, sizeof(command), "./%s", infile);
if (len <= 0 || len >= sizeof(command))
errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
result = sudo_goodpath(command, sbp);
if (result && ignore_dot)
found = sudo_goodpath(command, sbp);
if (found && ignore_dot)
debug_return_int(NOT_FOUND_DOT);
}
if (result) {
*outfile = result;
if (found) {
*outfile = command;
debug_return_int(FOUND);
} else
debug_return_int(NOT_FOUND);