die if fd_set overrun. (they're not setuid binary so it is not that critical)

This commit is contained in:
itojun 2002-08-09 02:17:26 +00:00
parent 258ffca8eb
commit 17110be88b
4 changed files with 24 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mapper.c,v 1.10 2002/07/14 15:34:58 wiz Exp $ */
/* $NetBSD: mapper.c,v 1.11 2002/08/09 02:17:26 itojun Exp $ */
/* Mapper for connections between MRouteD multicast routers.
* Written by Pavel Curtis <Pavel@PARC.Xerox.Com>
@ -906,6 +906,8 @@ int main(int argc, char **argv)
int count, recvlen, dummy = 0;
FD_ZERO(&fds);
if (igmp_socket >= FD_SETSIZE)
log(LOG_ERR, 0, "descriptor too big");
FD_SET(igmp_socket, &fds);
tv.tv_sec = timeout;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mld6.c,v 1.5 2002/07/20 08:40:18 grant Exp $ */
/* $NetBSD: mld6.c,v 1.6 2002/08/09 02:17:27 itojun Exp $ */
/* $KAME: mld6.c,v 1.9 2000/12/04 06:29:37 itojun Exp $ */
/*
@ -141,6 +141,8 @@ main(int argc, char *argv[])
(void)setitimer(ITIMER_REAL, &itimer, NULL);
FD_ZERO(&fdset);
if (s >= FD_SETSIZE)
errx(1, "descriptor too big");
for (;;) {
FD_SET(s, &fdset);
if ((i = select(s + 1, &fdset, NULL, NULL, NULL)) < 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: moused.c,v 1.6 2002/04/22 13:08:34 wiz Exp $ */
/* $NetBSD: moused.c,v 1.7 2002/08/09 02:17:28 itojun Exp $ */
/**
** Copyright (c) 1995 Michael Smith, All rights reserved.
**
@ -48,7 +48,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: moused.c,v 1.6 2002/04/22 13:08:34 wiz Exp $");
__RCSID("$NetBSD: moused.c,v 1.7 2002/08/09 02:17:28 itojun Exp $");
#endif /* not lint */
#include <ctype.h>
@ -904,11 +904,19 @@ moused(char *wsm)
for (;;) {
FD_ZERO(&fds);
if (rodent.mfd >= FD_SETSIZE)
logerr(1, "descriptor too big");
FD_SET(rodent.mfd, &fds);
if (rodent.mremsfd >= 0)
if (rodent.mremsfd >= 0) {
if (rodent.mremsfd >= FD_SETSIZE)
logerr(1, "descriptor too big");
FD_SET(rodent.mremsfd, &fds);
if (rodent.mremcfd >= 0)
}
if (rodent.mremcfd >= 0) {
if (rodent.mremcfd >= FD_SETSIZE)
logerr(1, "descriptor too big");
FD_SET(rodent.mremcfd, &fds);
}
c = select(FD_SETSIZE, &fds, NULL, NULL,
(rodent.flags & Emulate3Button) ? &timeout : NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.15 2002/07/14 16:30:42 wiz Exp $ */
/* $NetBSD: main.c,v 1.16 2002/08/09 02:17:29 itojun Exp $ */
/*
* The mrouted program is covered by the license in the accompanying file
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("@(#) $NetBSD: main.c,v 1.15 2002/07/14 16:30:42 wiz Exp $");
__RCSID("@(#) $NetBSD: main.c,v 1.16 2002/08/09 02:17:29 itojun Exp $");
#endif
#include <err.h>
@ -257,9 +257,13 @@ usage: fprintf(stderr,
(void)signal(SIGQUIT, dump);
FD_ZERO(&readers);
if (igmp_socket >= FD_SETSIZE)
log(LOG_ERR, 0, "descriptor too big");
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;