From 8f23f47c2cb28a2533bfeee9c7f2fafa778465fb Mon Sep 17 00:00:00 2001 From: Jun-ichiro itojun Hagino Date: Fri, 9 Aug 2002 02:12:16 +0000 Subject: avoid dynamically-generated string to printf. die if fd_set overruns. from xs@kittenz.org --- usr.sbin/mtrace/mtrace.c | 14 ++++++-------- 1 file 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 @@ -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"); -- cgit v1.2.3