Allocate and clear the correct number of bytes for a

struct fd_set that should be able to hold sock + 1 bits.
Before, it was apparently assumed that an fd_mask has
the same size as type char.

PR:		bin/39617
Reported by:	Peter N Lewis <peter@stairways.com.au>
This commit is contained in:
Robert Drehmel 2002-06-23 21:54:18 +00:00
parent 223071e10e
commit eac66622a0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98709

View File

@ -906,9 +906,9 @@ wait_for_reply(register int sock, register struct sockaddr_in *fromp,
int fromlen = sizeof(*fromp);
nfds = howmany(sock + 1, NFDBITS);
if ((fdsp = malloc(nfds)) == NULL)
if ((fdsp = malloc(nfds * sizeof(fd_mask))) == NULL)
err(1, "malloc");
memset(fdsp, 0, nfds);
memset(fdsp, 0, nfds * sizeof(fd_mask));
FD_SET(sock, fdsp);
wait.tv_sec = tp->tv_sec + waittime;