]> granicus.if.org Git - sudo/commitdiff
Now that we defer sending cstat until the end of script_child()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 26 May 2010 15:19:17 +0000 (11:19 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 26 May 2010 15:19:17 +0000 (11:19 -0400)
we cannot reuse cstat when reading command status from parent.

src/script.c

index 67edf06500ba9bd2b9e310fbbc1c6b775e752f0b..4a0e351e0b9786574a95de28a55b0613a1c790d9 100644 (file)
@@ -791,6 +791,7 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
                    cstat->type = CMD_ERRNO;
                    cstat->val = errno;
                }
+               break;
            }
            if (cstat->type == CMD_WSTATUS) {
                if (WIFSTOPPED(cstat->val)) {
@@ -1171,19 +1172,21 @@ script_child(struct command_details *details, char *argv[], char *envp[],
            errpipe[0] = -1;
        }
        if (FD_ISSET(backchannel, fdsr)) {
+           struct command_status cstmp;
+
            /* read command from backchannel, should be a signal */
-           n = recv(backchannel, &cstat, sizeof(cstat), 0);
+           n = recv(backchannel, &cstmp, sizeof(cstmp), 0);
            if (n == -1) {
                if (errno == EINTR)
                    continue;
                warning("error reading from socketpair");
                goto done;
            }
-           if (cstat.type != CMD_SIGNO) {
-               warningx("unexpected reply type on backchannel: %d", cstat.type);
+           if (cstmp.type != CMD_SIGNO) {
+               warningx("unexpected reply type on backchannel: %d", cstmp.type);
                continue;
            }
-           deliver_signal(child, cstat.val);
+           deliver_signal(child, cstmp.val);
        }
     }