From: Todd C. Miller Date: Sat, 3 Oct 2015 02:35:55 +0000 (-0600) Subject: Remove S_ISREG check from sudo_edit_open(), it is already done in X-Git-Tag: SUDO_1_8_15^2~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6dc5151d5d15604a0c6cd101220b820b8c5520c9;p=sudo Remove S_ISREG check from sudo_edit_open(), it is already done in the caller. --- diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 0eb91a89a..f6cfa338b 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -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.