]> granicus.if.org Git - sudo/commitdiff
Remove S_ISREG check from sudo_edit_open(), it is already done in
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 3 Oct 2015 02:35:55 +0000 (20:35 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 3 Oct 2015 02:35:55 +0000 (20:35 -0600)
the caller.

src/sudo_edit.c

index 0eb91a89a5990b6b071a7727f1565cd9207b8f5f..f6cfa338b1d7ce6d781b5d0f46c26336cd65aec0 100644 (file)
@@ -159,20 +159,12 @@ static int
 sudo_edit_open(const char *path, int oflags, mode_t mode, int sflags)
 {
     int fd;
-    struct stat sb;
 
     if (!ISSET(sflags, CD_SUDOEDIT_FOLLOW))
        oflags |= O_NOFOLLOW;
     fd = open(path, oflags|O_NONBLOCK, mode);
-    if (fd != -1) {
-       if (!ISSET(oflags, O_NONBLOCK))
-           (void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK);
-       if (fstat(fd, &sb) == -1 || !S_ISREG(sb.st_mode)) {
-           close(fd);
-           fd = -1;
-           errno = EINVAL;
-       }
-    }
+    if (fd != -1 && !ISSET(oflags, O_NONBLOCK))
+       (void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK);
     return fd;
 }
 #else
@@ -197,15 +189,6 @@ sudo_edit_open(const char *path, int oflags, mode_t mode, int sflags)
        return -1;
     }
 
-    /*
-     * Only open regular files.
-     */
-    if (!S_ISREG(sb1.st_mode)) {
-       close(fd);
-       errno = EINVAL;
-       return -1;
-    }
-
     /*
      * Make sure we did not open a link and that what we opened
      * matches what is currently on the file system.