public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] posix_spawn_file_actions_addfchdir_np: return EBADF on negative fd
@ 2023-04-19 19:09 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-04-19 19:09 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3124d8b436a8130130ffe9c6a397556ff0125e66
commit 3124d8b436a8130130ffe9c6a397556ff0125e66
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Wed Apr 19 20:48:14 2023 +0200
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Apr 19 20:48:14 2023 +0200
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>
Diff:
---
newlib/libc/posix/posix_spawn.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c
index 3506b0f8bffe..6fd6159d054d 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));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-19 19:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19 19:09 [newlib-cygwin/main] posix_spawn_file_actions_addfchdir_np: return EBADF on negative fd Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).