summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2015-07-09 20:16:05 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2015-07-09 20:16:05 +0000
commitb721c897983540efd176c2bf3329a471ab44a811 (patch)
treeda461398a6632e2303c2b7cd7dce0c99f756c0df /usr.sbin
parentff79cb0d2526ef420bb22ea37b88975da7a0c0e8 (diff)
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@
Diffstat (limited to 'usr.sbin')
-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))