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

@ -16,7 +16,6 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <spawn.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@ -30,11 +29,9 @@ posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions,
int fd, const char *path, int oflag,
mode_t mode)
{
int maxfd = __sysconf (_SC_OPEN_MAX);
struct __spawn_action *rec;
/* Test for the validity of the file descriptor. */
if (fd < 0 || fd >= maxfd)
if (!__spawn_valid_fd (fd))
return EBADF;
char *path_copy = strdup (path);