Check for FD_SET overruns.

Obtained from:	NetBSD
This commit is contained in:
nectar 2002-09-09 15:45:28 +00:00
parent 342bf9a702
commit 46adc04a10
4 changed files with 10 additions and 0 deletions

View File

@ -349,10 +349,14 @@ main(argc, argv)
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
if (igmp_socket >= FD_SETSIZE)
log(LOG_ERR, 0, "descriptor too big");
FD_ZERO(&readers);
FD_SET(igmp_socket, &readers);
nfds = igmp_socket + 1;
for (i = 0; i < nhandlers; i++) {
if (ihandlers[i].fd >= FD_SETSIZE)
log(LOG_ERR, 0, "descriptor too big");
FD_SET(ihandlers[i].fd, &readers);
if (ihandlers[i].fd >= nfds)
nfds = ihandlers[i].fd + 1;

View File

@ -943,6 +943,8 @@ int main(argc, argv)
struct timeval tv;
int count, recvlen, dummy = 0;
if (igmp_socket >= FD_SETSIZE)
log(LOG_ERR, 0, "descriptor too big");
FD_ZERO(&fds);
FD_SET(igmp_socket, &fds);

View File

@ -434,6 +434,8 @@ main(argc, argv)
struct igmp *igmp;
int ipdatalen, iphdrlen, igmpdatalen;
if (igmp_socket >= FD_SETSIZE)
log(LOG_ERR, 0, "descriptor too big");
FD_ZERO(&fds);
FD_SET(igmp_socket, &fds);

View File

@ -1276,6 +1276,8 @@ send_recv(dst, type, code, tries, save, callback)
* Wait for response, discarding false alarms
*/
while (TRUE) {
if (igmp_socket >= FD_SETSIZE)
log(LOG_ERR, 0, "descriptor too big");
FD_ZERO(&fds);
FD_SET(igmp_socket, &fds);
gettimeofday(&tv, 0);