From 3cf3a02c9a4f2f550522de70a6ae648c309afb36 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 1 Sep 1995 04:05:55 +0000 Subject: [PATCH] now set errno to EACCES if not a regular file or not executable --- goodpath.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/goodpath.c b/goodpath.c index b8d115327..12eaacb02 100644 --- a/goodpath.c +++ b/goodpath.c @@ -84,9 +84,16 @@ char * sudo_goodpath(path) /* discard root perms */ set_perms(PERM_USER); + /* stat(3) failed */ + if (!err) + return(NULL); + /* make sure path describes an executable regular file */ - if (!err && S_ISREG(statbuf.st_mode) &&(statbuf.st_mode & 0000111)) + if (S_ISREG(statbuf.st_mode) && (statbuf.st_mode & 0000111)) { return((char *)path); - else + } else { + /* file is not executable/regular */ + errno = EACCES; return(NULL); + } } -- 2.40.0