diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-01-18 09:58:24 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-01-18 09:58:24 +0000 |
commit | c1b507b9e100f5f3734586a23382d7dd5ac24244 (patch) | |
tree | afb951f94fa89ec4e653d5e2da6729b3db7b7538 /usr.sbin/npppd | |
parent | 1292adf806bbdffd0b14ac9112f8dde042da378b (diff) |
Convert privsep imsg code to use imsg_get_fd().
ok yasuoka
Diffstat (limited to 'usr.sbin/npppd')
-rw-r--r-- | usr.sbin/npppd/npppd/privsep.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/usr.sbin/npppd/npppd/privsep.c b/usr.sbin/npppd/npppd/privsep.c index 81b25749d91..6736a9779d7 100644 --- a/usr.sbin/npppd/npppd/privsep.c +++ b/usr.sbin/npppd/npppd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.24 2020/01/23 00:17:27 dlg Exp $ */ +/* $OpenBSD: privsep.c,v 1.25 2024/01/18 09:58:23 claudio Exp $ */ /* * Copyright (c) 2010 Yasuoka Masahiko <yasuoka@openbsd.org> @@ -526,7 +526,7 @@ privsep_recvfd(void) if (r->retval != 0) errno = r->rerrno; else - retval = imsg.fd; + retval = imsg_get_fd(&imsg); } imsg_free(&imsg); @@ -646,18 +646,19 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) case PRIVSEP_BIND: { struct PRIVSEP_BIND_ARG *a = imsg.data; struct PRIVSEP_COMMON_RESP r = { -1, 0 }; + int fd; if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(*a) || - imsg.fd < 0) + (fd = imsg_get_fd(&imsg)) < 0) r.rerrno = EINVAL; else if (privsep_npppd_check_bind(a)) r.rerrno = EACCES; else { - if ((r.retval = bind(imsg.fd, + if ((r.retval = bind(fd, (struct sockaddr *)&a->name, a->namelen)) != 0) r.rerrno = errno; - close(imsg.fd); + close(fd); } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); @@ -744,28 +745,29 @@ on_broken_entry: case PRIVSEP_SENDTO: { struct PRIVSEP_SENDTO_ARG *a = imsg.data; struct PRIVSEP_COMMON_RESP r = { -1, 0 }; + int fd; if (imsg.hdr.len < IMSG_HEADER_SIZE + sizeof(*a) || imsg.hdr.len < IMSG_HEADER_SIZE + offsetof(struct PRIVSEP_SENDTO_ARG, msg[a->len])) r.rerrno = EMSGSIZE; - else if (imsg.fd < 0) + else if ((fd = imsg_get_fd(&imsg)) < 0) r.rerrno = EINVAL; else if (privsep_npppd_check_sendto(a)) r.rerrno = EACCES; else { if (a->tolen > 0) - r.retval = sendto(imsg.fd, a->msg, + r.retval = sendto(fd, a->msg, a->len, a->flags, (struct sockaddr *)&a->to, a->tolen); else - r.retval = send(imsg.fd, a->msg, a->len, + r.retval = send(fd, a->msg, a->len, a->flags); if (r.retval < 0) r.rerrno = errno; - close(imsg.fd); + close(fd); } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); |