fail posix_spawn file_actions operations with negative fds
[musl] / src / process / posix_spawn_file_actions_adddup2.c
index 0367498..addca4d 100644 (file)
@@ -5,6 +5,7 @@
 
 int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int srcfd, int fd)
 {
+       if (srcfd < 0 || fd < 0) return EBADF;
        struct fdop *op = malloc(sizeof *op);
        if (!op) return ENOMEM;
        op->cmd = FDOP_DUP2;