diff options
author | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2014-07-13 21:34:36 +0000 |
---|---|---|
committer | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2014-07-13 21:34:36 +0000 |
commit | 3322d8e6879b068f525adf33a488beff3fdaa15b (patch) | |
tree | bd7bf97c9caed511a35cb1f5de43a14d94e3c817 /usr.sbin/npppd | |
parent | 86ba5a59e1814f403ee6946fc2f0e1d6a7da38ab (diff) |
Some functions need to dup() before sending a socket by imsg and don't
need to close() after sending socket since imsg_compose() closes the
passing socket.
Diffstat (limited to 'usr.sbin/npppd')
-rw-r--r-- | usr.sbin/npppd/npppd/privsep.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/npppd/npppd/privsep.c b/usr.sbin/npppd/npppd/privsep.c index 5c79fa07b69..bdb5a1b64a7 100644 --- a/usr.sbin/npppd/npppd/privsep.c +++ b/usr.sbin/npppd/npppd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.12 2014/07/12 20:07:07 yasuoka Exp $ */ +/* $OpenBSD: privsep.c,v 1.13 2014/07/13 21:34:35 yasuoka Exp $ */ /* * Copyright (c) 2010 Yasuoka Masahiko <yasuoka@openbsd.org> @@ -234,6 +234,9 @@ priv_bind(int sock, const struct sockaddr *name, socklen_t namelen) errno = EINVAL; return (-1); } + if ((sock = dup(sock)) == -1) + return (-1); + memcpy(&a.name, name, namelen); a.namelen = namelen; @@ -296,6 +299,8 @@ priv_sendto(int s, const void *msg, int len, int flags, errno = EINVAL; return (-1); } + if ((s = dup(s)) == -1) + return (-1); a.len = len; a.flags = flags; @@ -581,7 +586,6 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, f, &r, sizeof(r)); imsg_flush(ibuf); - close(f); } break; case PRIVSEP_SOCKET: { @@ -603,7 +607,6 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, s, &r, sizeof(r)); imsg_flush(ibuf); - close(s); } break; case PRIVSEP_UNLINK: { |