1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Improve file descriptor checks for posix_spawn actions [BZ #19505]

This commit is contained in:
Florian Weimer
2016-02-19 14:49:38 +01:00
parent ff889b1965
commit 6793dd51d8
8 changed files with 249 additions and 12 deletions

View File

@ -27,11 +27,9 @@ int
posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *file_actions,
int fd, int newfd)
{
int maxfd = __sysconf (_SC_OPEN_MAX);
struct __spawn_action *rec;
/* Test for the validity of the file descriptor. */
if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd)
if (!__spawn_valid_fd (fd) || !__spawn_valid_fd (newfd))
return EBADF;
/* Allocate more memory if needed. */