diff options
author | Rich Felker <dalias@aerifal.cx> | 2021-01-30 16:09:22 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2021-01-30 16:09:22 -0500 |
commit | dd5b6384712fb554bb6e291f2bbcdc9ec2f66554 (patch) | |
tree | 4763fc81ee12d9c546ac49dc2b2725a4c9181c0b /src/process/posix_spawn_file_actions_addclose.c | |
parent | 85e0e3519655220688e757b9d5bfd314923548bd (diff) | |
download | musl-dd5b6384712fb554bb6e291f2bbcdc9ec2f66554.tar.gz musl-dd5b6384712fb554bb6e291f2bbcdc9ec2f66554.tar.bz2 musl-dd5b6384712fb554bb6e291f2bbcdc9ec2f66554.tar.xz musl-dd5b6384712fb554bb6e291f2bbcdc9ec2f66554.zip |
fail posix_spawn file_actions operations with negative fds
these functions are specified to fail with EBADF on negative fd
arguments. apart from close, they are also specified to fail if the
value exceeds OPEN_MAX, but as written it is not clear that this
imposes any requirement when OPEN_MAX is not defined, and it's
undesirable to impose a dynamic limit (via setrlimit) here since the
limit at the time of posix_spawn may be different from the limit at
the time of setting up the file actions. this may require revisiting
later.
Diffstat (limited to 'src/process/posix_spawn_file_actions_addclose.c')
-rw-r--r-- | src/process/posix_spawn_file_actions_addclose.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/process/posix_spawn_file_actions_addclose.c b/src/process/posix_spawn_file_actions_addclose.c index cdda5979..0c2ef8fa 100644 --- a/src/process/posix_spawn_file_actions_addclose.c +++ b/src/process/posix_spawn_file_actions_addclose.c @@ -5,6 +5,7 @@ int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd) { + if (fd < 0) return EBADF; struct fdop *op = malloc(sizeof *op); if (!op) return ENOMEM; op->cmd = FDOP_CLOSE; |