summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2015-07-09 20:16:04 +0000
committerbluhm <bluhm@openbsd.org>2015-07-09 20:16:04 +0000
commitbd0bd7edae8a7e9bca5675891234528cd74ef9d8 (patch)
treeaa927dfecf9ad51948277000931575b38b4cdd2b
parentNuke unused variable. (diff)
downloadwireguard-openbsd-bd0bd7edae8a7e9bca5675891234528cd74ef9d8.tar.xz
wireguard-openbsd-bd0bd7edae8a7e9bca5675891234528cd74ef9d8.zip
During fd passing, receive_fd() tries to read the result value and
the file descriptor. If the fd limit is exhausted, recvmsg(2) fails. The kernel discards the fd, but the result value stays in the socket. It has to be read on its own to keep the privsep parent and syslogd child in sync. OK benno@
-rw-r--r--usr.sbin/syslogd/privsep_fdpass.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.sbin/syslogd/privsep_fdpass.c b/usr.sbin/syslogd/privsep_fdpass.c
index 94f32d199b5..4ef9d107580 100644
--- a/usr.sbin/syslogd/privsep_fdpass.c
+++ b/usr.sbin/syslogd/privsep_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep_fdpass.c,v 1.10 2015/07/06 16:12:16 millert Exp $ */
+/* $OpenBSD: privsep_fdpass.c,v 1.11 2015/07/09 20:16:04 bluhm Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -104,6 +104,9 @@ receive_fd(int sock)
if ((n = recvmsg(sock, &msg, 0)) == -1) {
warn("%s: recvmsg", "receive_fd");
+ /* receive message failed, but the result is in the socket */
+ if (errno == EMSGSIZE)
+ recv(sock, &result, sizeof(int), MSG_DONTWAIT);
return -1;
}
if (n != sizeof(int))