--- embedaddon/sudo/plugins/sudoers/goodpath.c 2012/02/21 16:23:02 1.1.1.1 +++ embedaddon/sudo/plugins/sudoers/goodpath.c 2013/07/22 10:46:12 1.1.1.3 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 1998-2005, 2010-2011 + * Copyright (c) 1996, 1998-2005, 2010-2012 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any @@ -23,7 +23,6 @@ #include #include -#include #include #ifdef HAVE_STRING_H # include @@ -41,25 +40,22 @@ /* * Verify that path is a normal file and executable by root. */ -char * +bool sudo_goodpath(const char *path, struct stat *sbp) { struct stat sb; + bool rval = false; + debug_decl(sudo_goodpath, SUDO_DEBUG_UTIL) - /* Check for brain damage */ - if (path == NULL || path[0] == '\0') - return NULL; - - if (stat(path, &sb)) - return NULL; - - /* Make sure path describes an executable regular file. */ - if (!S_ISREG(sb.st_mode) || !(sb.st_mode & 0000111)) { - errno = EACCES; - return NULL; + if (path != NULL && stat(path, &sb) == 0) { + /* Make sure path describes an executable regular file. */ + if (S_ISREG(sb.st_mode) && ISSET(sb.st_mode, 0111)) + rval = true; + else + errno = EACCES; + if (sbp) + (void) memcpy(sbp, &sb, sizeof(struct stat)); } - if (sbp != NULL) - (void) memcpy(sbp, &sb, sizeof(struct stat)); - return (char *)path; + debug_return_bool(rval); }