From f4c402e7c744b8ca1421a23ed69a675e75abca66 Mon Sep 17 00:00:00 2001 From: Simon Gaiser Date: Thu, 15 Mar 2018 20:32:27 +0100 Subject: [PATCH] qrexec-fork-server: Always initialize addrlen argument of accept() With the old code the addrlen argument were uninitialized on the first call resulting in errors depending on the compiler behavior. --- qrexec/qrexec-fork-server.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qrexec/qrexec-fork-server.c b/qrexec/qrexec-fork-server.c index 43bfd54..6c5eb98 100644 --- a/qrexec/qrexec-fork-server.c +++ b/qrexec/qrexec-fork-server.c @@ -112,12 +112,15 @@ int main(int argc, char **argv) { signal(SIGCHLD, SIG_IGN); register_exec_func(do_exec); - while ((fd = accept(s, (struct sockaddr *) &peer, &addrlen)) >= 0) { + while (1) { + addrlen = sizeof(peer); + fd = accept(s, (struct sockaddr *) &peer, &addrlen); + if (fd < 0) + break; if (read_all(fd, &info, sizeof(info))) { handle_single_command(fd, &info); } close(fd); - addrlen = sizeof(peer); } close(s); unlink(socket_path);