git: 8ff4fc03e693 - main - traceroute6: fix capabilities for the rcv socket
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 04 Oct 2022 21:40:35 UTC
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=8ff4fc03e6933dd69f99a8f34f2aa0760300f248 commit 8ff4fc03e6933dd69f99a8f34f2aa0760300f248 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2022-10-04 21:34:58 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2022-10-04 21:40:29 +0000 traceroute6: fix capabilities for the rcv socket On the receive socket, recvmsg() and poll()/select() is called. Therefore, CAP_EVENT is needed in addition to CAP_RECV.. While there, check the socket for readbility before calling recvmsg(). Reviewed by: markj@ MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D36878 --- usr.sbin/traceroute6/traceroute6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c index a071c084ad07..d887acf5ae53 100644 --- a/usr.sbin/traceroute6/traceroute6.c +++ b/usr.sbin/traceroute6/traceroute6.c @@ -937,7 +937,7 @@ main(int argc, char *argv[]) strerror(errno)); exit(1); } - cap_rights_init(&rights, CAP_RECV); + cap_rights_init(&rights, CAP_RECV, CAP_EVENT); if (caph_rights_limit(rcvsock, &rights) < 0) { fprintf(stderr, "caph_rights_limit rcvsock: %s\n", strerror(errno)); @@ -1039,7 +1039,8 @@ wait_for_reply(int sock, struct msghdr *mhdr) pfd[0].events = POLLIN; pfd[0].revents = 0; - if (poll(pfd, 1, waittime * 1000) > 0) + if (poll(pfd, 1, waittime * 1000) > 0 && + pfd[0].revents & POLLIN) cc = recvmsg(rcvsock, mhdr, 0); return (cc);