Remove S_ISREG check from sudo_edit_open(), it is already done in
the caller.
This commit is contained in:
@@ -159,20 +159,12 @@ static int
|
|||||||
sudo_edit_open(const char *path, int oflags, mode_t mode, int sflags)
|
sudo_edit_open(const char *path, int oflags, mode_t mode, int sflags)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
if (!ISSET(sflags, CD_SUDOEDIT_FOLLOW))
|
if (!ISSET(sflags, CD_SUDOEDIT_FOLLOW))
|
||||||
oflags |= O_NOFOLLOW;
|
oflags |= O_NOFOLLOW;
|
||||||
fd = open(path, oflags|O_NONBLOCK, mode);
|
fd = open(path, oflags|O_NONBLOCK, mode);
|
||||||
if (fd != -1) {
|
if (fd != -1 && !ISSET(oflags, O_NONBLOCK))
|
||||||
if (!ISSET(oflags, O_NONBLOCK))
|
(void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -197,15 +189,6 @@ sudo_edit_open(const char *path, int oflags, mode_t mode, int sflags)
|
|||||||
return -1;
|
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
|
* Make sure we did not open a link and that what we opened
|
||||||
* matches what is currently on the file system.
|
* matches what is currently on the file system.
|
||||||
|
Reference in New Issue
Block a user