fail posix_spawn file_actions operations with negative fds
[musl] / src / process / posix_spawn_file_actions_addopen.c
index 368922c..82bbcec 100644 (file)
@@ -6,6 +6,7 @@
 
 int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)
 {
+       if (fd < 0) return EBADF;
        struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
        if (!op) return ENOMEM;
        op->cmd = FDOP_OPEN;