summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-07-08 19:32:27 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-07-08 19:32:27 +0000
commit854e1b47b7ccd93f2e78444a947262fa111c17cb (patch)
tree04079ea9b264714e07c962709ebb7ea14e8e66b9 /usr.sbin
parentcc7a429a385f945e0b4a419bcb5665ccaaabc174 (diff)
When making a copy of svc_pollfd, use the correct size.
Also pass the correct fd count to svc_getreq_poll(). OK jca@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ypbind/ypbind.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c
index 802c25fc5e3..518997409d2 100644
--- a/usr.sbin/ypbind/ypbind.c
+++ b/usr.sbin/ypbind/ypbind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypbind.c,v 1.67 2016/07/05 16:41:40 jca Exp $ */
+/* $OpenBSD: ypbind.c,v 1.68 2016/07/08 19:32:26 millert Exp $ */
/*
* Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org>
@@ -338,7 +338,7 @@ main(int argc, char *argv[])
char path[PATH_MAX];
struct sockaddr_in sin;
struct pollfd *pfd = NULL;
- int width = 0, lockfd, lsock;
+ int width = 0, nready, lockfd, lsock;
socklen_t len;
int evil = 0, one = 1;
DIR *dirp;
@@ -540,9 +540,10 @@ main(int argc, char *argv[])
pfd[0].events = POLLIN;
pfd[1].fd = pingsock;
pfd[1].events = POLLIN;
- memcpy(pfd + 2, svc_pollfd, svc_max_pollfd);
+ memcpy(pfd + 2, svc_pollfd, sizeof(*pfd) * svc_max_pollfd);
- switch (poll(pfd, width, 1000)) {
+ nready = poll(pfd, width, 1000);
+ switch (nready) {
case 0:
checkwork();
break;
@@ -552,11 +553,15 @@ main(int argc, char *argv[])
break;
default:
/* No need to check for POLLHUP on UDP sockets. */
- if (pfd[0].revents & POLLIN)
+ if (pfd[0].revents & POLLIN) {
handle_replies();
- if (pfd[1].revents & POLLIN)
+ nready--;
+ }
+ if (pfd[1].revents & POLLIN) {
handle_ping();
- svc_getreq_poll(pfd + 2, svc_max_pollfd);
+ nready--;
+ }
+ svc_getreq_poll(pfd + 2, nready);
if (check)
checkwork();
break;