summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-08-09 02:12:16 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-08-09 02:12:16 +0000
commit8f23f47c2cb28a2533bfeee9c7f2fafa778465fb (patch)
tree9f1c84b63ab57bbdec64906b2c012df99e41508c
parenta10440cfdc60ff57b5bb923a26acdedd9f990df7 (diff)
avoid dynamically-generated string to printf. die if fd_set overruns.
from xs@kittenz.org
-rw-r--r--usr.sbin/mtrace/mtrace.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/usr.sbin/mtrace/mtrace.c b/usr.sbin/mtrace/mtrace.c
index 47c031b0f34..9ec63249cb0 100644
--- a/usr.sbin/mtrace/mtrace.c
+++ b/usr.sbin/mtrace/mtrace.c
@@ -52,7 +52,7 @@
#ifndef lint
static char rcsid[] =
- "@(#) $Id: mtrace.c,v 1.14 2002/06/14 21:35:01 todd Exp $";
+ "@(#) $Id: mtrace.c,v 1.15 2002/08/09 02:12:15 itojun Exp $";
#endif
#include <netdb.h>
@@ -457,6 +457,8 @@ send_recv(dst, type, code, tries, save)
*/
while (TRUE) {
FD_ZERO(&fds);
+ if (igmp_socket >= FD_SETSIZE)
+ log(LOG_ERR, 0, "descriptor too big");
FD_SET(igmp_socket, &fds);
gettimeofday(&tv, 0);
tv.tv_sec = tq.tv_sec + timeout - tv.tv_sec;
@@ -625,8 +627,6 @@ passive_mode()
int len, recvlen, dummy = 0;
u_int32_t smask;
- init_igmp();
-
if (raddr) {
if (IN_MULTICAST(ntohl(raddr))) k_join(raddr, INADDR_ANY);
} else k_join(htonl(0xE0000120), INADDR_ANY);
@@ -1676,18 +1676,16 @@ void
log(int severity, int syserr, char *format, ...)
{
va_list ap;
- char fmt[100];
switch (debug) {
case 0: if (severity > LOG_WARNING) return;
case 1: if (severity > LOG_NOTICE) return;
case 2: if (severity > LOG_INFO ) return;
default:
- fmt[0] = '\0';
- if (severity == LOG_WARNING) strcat(fmt, "warning - ");
- strncat(fmt, format, 80);
+ if (severity == LOG_WARNING)
+ fprintf(stderr, "warning - ");
va_start(ap, format);
- vfprintf(stderr, fmt, ap);
+ vfprintf(stderr, format, ap);
va_end(ap);
if (syserr == 0)
fprintf(stderr, "\n");