aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2023-04-19 20:48:14 +0200
committerCorinna Vinschen <corinna@vinschen.de>2023-04-19 20:48:14 +0200
commit3124d8b436a8130130ffe9c6a397556ff0125e66 (patch)
treeb7838a4b510cef4ee06451de18ef61e1cde53ba6 /newlib/libc
parent53f7fb20a064fec180291a497d11eb66fe6172e6 (diff)
downloadnewlib-3124d8b436a8130130ffe9c6a397556ff0125e66.zip
newlib-3124d8b436a8130130ffe9c6a397556ff0125e66.tar.gz
newlib-3124d8b436a8130130ffe9c6a397556ff0125e66.tar.bz2
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/libc')
-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 3506b0f..6fd6159 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));