summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2000-10-10 12:37:07 +0000
committerderaadt <deraadt@openbsd.org>2000-10-10 12:37:07 +0000
commitefccc0fe80473a3c98bacf83417f1dbe18c8f510 (patch)
tree6091a8be812c0f909bb1e1eca0b8e883611acd41
parentUse supplied vax support. Don't know if it works. (diff)
downloadwireguard-openbsd-efccc0fe80473a3c98bacf83417f1dbe18c8f510.tar.xz
wireguard-openbsd-efccc0fe80473a3c98bacf83417f1dbe18c8f510.zip
use poll to avoid fd_set overflow
-rw-r--r--libexec/identd/parse.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libexec/identd/parse.c b/libexec/identd/parse.c
index 5599cb72413..4adb647c13e 100644
--- a/libexec/identd/parse.c
+++ b/libexec/identd/parse.c
@@ -13,6 +13,7 @@
#include <netinet/in.h>
#include <stdio.h>
+#include <poll.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -85,18 +86,20 @@ timed_read(fd, buf, siz, timeout)
{
int error, tot = 0, i, r;
char *p = buf;
- fd_set readfds;
+ struct pollfd rfd[1];
struct timeval tv, start, after, duration, tmp;
tv.tv_sec = timeout;
tv.tv_usec = 0;
while (1) {
- FD_ZERO(&readfds);
- FD_SET(fd, &readfds);
+ rfd[0].fd = fd;
+ rfd[0].events = POLLIN;
+ rfd[0].revents = 0;
gettimeofday(&start, NULL);
- if ((error = select(fd + 1, &readfds, 0, 0, &tv)) <= 0)
+ if ((error = poll(rfd, 1, tv.tv_sec * 1000 +
+ tv.tv_usec / 1000)) <= 0)
return error;
r = read(fd, p, siz - tot);
if (r == -1 || r == 0)