Diff for /embedaddon/sudo/plugins/sudoers/goodpath.c between versions 1.1 and 1.1.1.2

version 1.1, 2012/02/21 16:23:02 version 1.1.1.2, 2012/05/29 12:26:49
Line 41 Line 41
 /*  /*
  * Verify that path is a normal file and executable by root.   * Verify that path is a normal file and executable by root.
  */   */
char *bool
 sudo_goodpath(const char *path, struct stat *sbp)  sudo_goodpath(const char *path, struct stat *sbp)
 {  {
     struct stat sb;      struct stat sb;
       bool rval = false;
       debug_decl(sudo_goodpath, SUDO_DEBUG_UTIL)
   
    /* Check for brain damage */    if (path != NULL && stat(path, &sb) == 0) {
    if (path == NULL || path[0] == '\0')        /* Make sure path describes an executable regular file. */
        return NULL;        if (S_ISREG(sb.st_mode) && ISSET(sb.st_mode, 0111))
            rval = true;
    if (stat(path, &sb))        else
        return NULL;            errno = EACCES;
        if (sbp)
    /* Make sure path describes an executable regular file. */            (void) memcpy(sbp, &sb, sizeof(struct stat));
    if (!S_ISREG(sb.st_mode) || !(sb.st_mode & 0000111)) { 
        errno = EACCES; 
        return NULL; 
     }      }
   
    if (sbp != NULL)    debug_return_bool(rval);
        (void) memcpy(sbp, &sb, sizeof(struct stat)); 
    return (char *)path; 
 }  }

Removed from v.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>