Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2023-04-19 21:48:14 +0300
committerCorinna Vinschen <corinna@vinschen.de>2023-04-19 21:48:14 +0300
commit3124d8b436a8130130ffe9c6a397556ff0125e66 (patch)
treeb7838a4b510cef4ee06451de18ef61e1cde53ba6 /newlib
parent53f7fb20a064fec180291a497d11eb66fe6172e6 (diff)
posix_spawn_file_actions_addfchdir_np: return EBADF on negative fd
FreeBSD and Musl implement posix_spawn_file_actions_addfchdir_np so that it checks the incoming descriptor for being negative, and, if so, return with EBADF. The POSIX proposal defining posix_spawn_file_actions_addfchdir follows this behaviour, see https://www.austingroupbugs.net/view.php?id=1208 Fixes: 7e03fc35f528 ("Add posix_spawn_file_actions_add{f}chdir_np") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'newlib')
-rw-r--r--newlib/libc/posix/posix_spawn.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c
index 3506b0f8b..6fd6159d0 100644
--- a/newlib/libc/posix/posix_spawn.c
+++ b/newlib/libc/posix/posix_spawn.c
@@ -565,7 +565,12 @@ posix_spawn_file_actions_addfchdir_np (
int fd)
{
posix_spawn_file_actions_entry_t *fae;
- int error;
+
+ /* POSIX proposal documents it as implemented in FreeBSD and Musl.
+ Return EBADF if fd is negative.
+ https://www.austingroupbugs.net/view.php?id=1208 */
+ if (fd < 0)
+ return EBADF;
/* Allocate object */
fae = malloc(sizeof(posix_spawn_file_actions_entry_t));