summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-12-17 07:40:43 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-12-17 07:40:43 +0000
commit02925b9d061b28785a08ed3e84389b8ee1f230ce (patch)
tree18a2d1e29f2322a3fef9d3d235a740373a5fc654
parent445d92b5126efaafe35e9771f6cc5a0dd1b5e2e2 (diff)
make fd_set not overflow
-rw-r--r--usr.sbin/amd/amd/info_hes.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/amd/amd/info_hes.c b/usr.sbin/amd/amd/info_hes.c
index d0b0314f0f3..55ba86c6859 100644
--- a/usr.sbin/amd/amd/info_hes.c
+++ b/usr.sbin/amd/amd/info_hes.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_hes.c 8.1 (Berkeley) 6/6/93
- * $Id: info_hes.c,v 1.3 1997/06/23 01:36:00 deraadt Exp $
+ * $Id: info_hes.c,v 1.4 1997/12/17 07:40:42 deraadt Exp $
*/
/*
@@ -396,16 +396,22 @@ hs_res_selwait(sock, timeout)
int sock;
struct timeval *timeout;
{
- fd_set dsmask;
+ fd_set *fdsp;
+ int fdsn;
register int n;
/*
* Wait for reply
*/
- FD_ZERO(&dsmask);
- FD_SET(sock, &dsmask);
- n = select(sock+1, &dsmask, (fd_set *)NULL,
+ fdsn = howmany(sock+1, NFDBITS) * sizeof(fd_mask);
+ if ((fdsp = (fd_set *)malloc(fdsn)) == NULL)
+ return(0);
+ memset(fdsp, 0, fdsn);
+
+ FD_SET(sock, fdsp);
+ n = select(sock+1, fdsp, (fd_set *)NULL,
(fd_set *)NULL, timeout);
+ free(fdsp);
return(n);
}