mirror of
https://github.com/fluencelabs/musl
synced 2025-06-27 13:41:57 +00:00
fix backwards posix_spawn file action order
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
#define FDOP_OPEN 3
|
#define FDOP_OPEN 3
|
||||||
|
|
||||||
struct fdop {
|
struct fdop {
|
||||||
struct fdop *next;
|
struct fdop *next, *prev;
|
||||||
int cmd, fd, newfd, oflag;
|
int cmd, fd, newfd, oflag;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
char path[];
|
char path[];
|
||||||
|
@ -51,10 +51,11 @@ int __posix_spawnx(pid_t *res, const char *path,
|
|||||||
__syscall(SYS_setuid, __syscall(SYS_getuid)) ))
|
__syscall(SYS_setuid, __syscall(SYS_getuid)) ))
|
||||||
_exit(127);
|
_exit(127);
|
||||||
|
|
||||||
if (fa) {
|
if (fa && fa->__actions) {
|
||||||
struct fdop *op;
|
struct fdop *op;
|
||||||
int ret, fd;
|
int ret, fd;
|
||||||
for (op = fa->__actions; op; op = op->next) {
|
for (op = fa->__actions; op->next; op = op->next);
|
||||||
|
for (; op; op = op->prev) {
|
||||||
switch(op->cmd) {
|
switch(op->cmd) {
|
||||||
case FDOP_CLOSE:
|
case FDOP_CLOSE:
|
||||||
ret = __syscall(SYS_close, op->fd);
|
ret = __syscall(SYS_close, op->fd);
|
||||||
|
@ -9,7 +9,8 @@ int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd)
|
|||||||
if (!op) return ENOMEM;
|
if (!op) return ENOMEM;
|
||||||
op->cmd = FDOP_CLOSE;
|
op->cmd = FDOP_CLOSE;
|
||||||
op->fd = fd;
|
op->fd = fd;
|
||||||
op->next = fa->__actions;
|
if ((op->next = fa->__actions)) op->next->prev = op;
|
||||||
|
op->prev = 0;
|
||||||
fa->__actions = op;
|
fa->__actions = op;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int fd, int
|
|||||||
op->cmd = FDOP_DUP2;
|
op->cmd = FDOP_DUP2;
|
||||||
op->fd = fd;
|
op->fd = fd;
|
||||||
op->newfd = newfd;
|
op->newfd = newfd;
|
||||||
op->next = fa->__actions;
|
if ((op->next = fa->__actions)) op->next->prev = op;
|
||||||
|
op->prev = 0;
|
||||||
fa->__actions = op;
|
fa->__actions = op;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *fa, int fd, con
|
|||||||
op->oflag = flags;
|
op->oflag = flags;
|
||||||
op->mode = mode;
|
op->mode = mode;
|
||||||
strcpy(op->path, path);
|
strcpy(op->path, path);
|
||||||
op->next = fa->__actions;
|
if ((op->next = fa->__actions)) op->next->prev = op;
|
||||||
|
op->prev = 0;
|
||||||
fa->__actions = op;
|
fa->__actions = op;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user