Skip to content

Commit

Permalink
Avoid writing to an uninitialized file descriptor
Browse files Browse the repository at this point in the history
Found by clang-tidy.  No tests, but the fix is trivial.

Fixes: 3d658cc ("Use a pipe instead of signals to notify readiness")
  • Loading branch information
DemiMarie committed Apr 23, 2024
1 parent 31e412f commit 6d66051
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions daemon/qrexec-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ static const char default_user_keyword[] = "DEFAULT:";
#define default_user_keyword_len_without_colon (sizeof(default_user_keyword)-2)

static int opt_quiet = 0;
static int opt_direct = 0;

static const char *policy_program = QREXEC_POLICY_PROGRAM;

Expand Down Expand Up @@ -268,7 +267,7 @@ static int handle_agent_hello(libvchan_t *ctrl, const char *domain_name)
static void signal_handler(int sig);

/* do the preparatory tasks, needed before entering the main event loop */
static void init(int xid)
static void init(int xid, bool opt_direct)
{
char qrexec_error_log_name[256];
int logfd;
Expand Down Expand Up @@ -376,7 +375,7 @@ static void init(int xid)
}
if (qubes_wait_for_vchan_connection_with_timeout(
vchan, wait_fd, false, startup_timeout) < 0) {
if (write(pipes[1], "\1", 1)) {}
if (!opt_direct && write(pipes[1], "\1", 1)) {}

Check warning on line 378 in daemon/qrexec-daemon.c

View check run for this annotation

Codecov / codecov/patch

daemon/qrexec-daemon.c#L378

Added line #L378 was not covered by tests
LOG(ERROR, "qrexec connection timeout");
exit(3);
}
Expand Down Expand Up @@ -1570,6 +1569,7 @@ int main(int argc, char **argv)
{
int i, opt;
sigset_t selectmask;
bool opt_direct = false;

{
int null_fd = open("/dev/null", O_RDONLY|O_NOCTTY);
Expand Down Expand Up @@ -1613,7 +1613,7 @@ int main(int argc, char **argv)
remote_domain_name = argv[optind+1];
if (argc - optind >= 3)
default_user = argv[optind+2];
init(remote_domain_id);
init(remote_domain_id, opt_direct);

sigemptyset(&selectmask);
sigaddset(&selectmask, SIGCHLD);
Expand Down

0 comments on commit 6d66051

Please sign in to comment.