diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-01-11 23:38:08 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-01-11 23:38:08 +0000 |
commit | 4acc60cf37f39c5adb19a802bcd83380a9874478 (patch) | |
tree | 4fa95d97f81eec49569947f4166811139e4e0984 | |
parent | 368b1559a73c82c0128be302e073ab6c81a7f432 (diff) |
fix fd_set overflow
-rw-r--r-- | usr.sbin/ypserv/yppush/yppush.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c index 0b1ec49dd87..3f793503991 100644 --- a/usr.sbin/ypserv/yppush/yppush.c +++ b/usr.sbin/ypserv/yppush/yppush.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yppush.c,v 1.12 2000/10/12 09:47:27 deraadt Exp $ */ +/* $OpenBSD: yppush.c,v 1.13 2001/01/11 23:38:07 deraadt Exp $ */ /* * Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se> @@ -32,7 +32,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: yppush.c,v 1.12 2000/10/12 09:47:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: yppush.c,v 1.13 2001/01/11 23:38:07 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -80,15 +80,27 @@ usage() void _svc_run() { - fd_set readfds; + fd_set *readfdsp = NULL; + extern fd_set *__svc_fdset; + extern int __svc_fdsetsize; struct timeval timeout; timeout.tv_sec = 60; timeout.tv_usec = 0; for (;;) { - readfds = svc_fdset; - switch (select(_rpc_dtablesize(), &readfds, NULL, + if (readfdsp) + free(readfdsp); + readfdsp = (fd_set *)calloc(howmany(__svc_fdsetsize, NFDBITS), + sizeof(fd_mask)); + if (readfdsp == NULL) { + perror("calloc"); + return; + } + bcopy(__svc_fdset, readfdsp, howmany(__svc_fdsetsize, NFDBITS) * + sizeof(fd_mask)); + + switch (select(svc_maxfd, readfdsp, NULL, NULL, &timeout)) { case -1: if (errno == EINTR) @@ -99,7 +111,7 @@ _svc_run() fprintf(stderr, "yppush: Callback timed out.\n"); exit(0); default: - svc_getreqset(&readfds); + svc_getreqset(readfdsp); break; } } |