From 5f03b8a2839711ce62ab685533b4d34f02b3f450 Mon Sep 17 00:00:00 2001 From: AZero13 Date: Tue, 16 Dec 2025 22:23:59 -0500 Subject: [PATCH] We ought to be checking type, not val, for CMD_INVALID --- src/exec_monitor.c | 2 +- src/exec_nopty.c | 2 +- src/exec_pty.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/exec_monitor.c b/src/exec_monitor.c index 1ffeee2995..2ecad5e68e 100644 --- a/src/exec_monitor.c +++ b/src/exec_monitor.c @@ -276,7 +276,7 @@ mon_errsock_cb(int fd, int what, void *v) nread = read(fd, &errval, sizeof(errval)); if (nread < 0) { if (errno != EAGAIN && errno != EINTR) { - if (mc->cstat->val == CMD_INVALID) { + if (mc->cstat->type == CMD_INVALID) { /* XXX - need a way to distinguish non-exec error. */ mc->cstat->type = CMD_ERRNO; mc->cstat->val = errno; diff --git a/src/exec_nopty.c b/src/exec_nopty.c index 3ab70e5ea6..4cd0c7da48 100644 --- a/src/exec_nopty.c +++ b/src/exec_nopty.c @@ -82,7 +82,7 @@ errpipe_cb(int fd, int what, void *v) switch (nread) { case -1: if (errno != EAGAIN && errno != EINTR) { - if (ec->cstat->val == CMD_INVALID) { + if (ec->cstat->type == CMD_INVALID) { /* XXX - need a way to distinguish non-exec error. */ ec->cstat->type = CMD_ERRNO; ec->cstat->val = errno; diff --git a/src/exec_pty.c b/src/exec_pty.c index ed2c77f854..161c83215b 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -678,7 +678,7 @@ backchannel_cb(int fd, int what, void *v) /* Nothing ready. */ break; default: - if (ec->cstat->val == CMD_INVALID) { + if (ec->cstat->type == CMD_INVALID) { ec->cstat->type = CMD_ERRNO; ec->cstat->val = errno; sudo_debug_printf(SUDO_DEBUG_ERROR, @@ -752,7 +752,7 @@ backchannel_cb(int fd, int what, void *v) break; default: /* Short read, should not happen. */ - if (ec->cstat->val == CMD_INVALID) { + if (ec->cstat->type == CMD_INVALID) { ec->cstat->type = CMD_ERRNO; ec->cstat->val = EIO; sudo_debug_printf(SUDO_DEBUG_ERROR, @@ -1443,7 +1443,7 @@ exec_pty(struct command_details *details, /* error from callback */ sudo_debug_printf(SUDO_DEBUG_ERROR, "event loop exited prematurely"); /* XXX: no good way to know if we should terminate the command. */ - if (cstat->val == CMD_INVALID && ec->cmnd_pid != -1) { + if (cstat->type == CMD_INVALID && ec->cmnd_pid != -1) { /* no status message, kill command */ terminate_command(ec->cmnd_pid, true); ec->cmnd_pid = -1;