From 02925b9d061b28785a08ed3e84389b8ee1f230ce Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 17 Dec 1997 07:40:43 +0000 Subject: make fd_set not overflow --- usr.sbin/amd/amd/info_hes.c | 16 +++++++++++----- 1 file 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); } -- cgit v1.2.3