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: 7e03fc35f5
("Add posix_spawn_file_actions_add{f}chdir_np")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
53f7fb20a0
commit
3124d8b436
|
@ -565,7 +565,12 @@ posix_spawn_file_actions_addfchdir_np (
|
||||||
int fd)
|
int fd)
|
||||||
{
|
{
|
||||||
posix_spawn_file_actions_entry_t *fae;
|
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 */
|
/* Allocate object */
|
||||||
fae = malloc(sizeof(posix_spawn_file_actions_entry_t));
|
fae = malloc(sizeof(posix_spawn_file_actions_entry_t));
|
||||||
|
|
Loading…
Reference in New Issue