Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/mtrace revoke root priv earlier. check fd_set over...
details: https://anonhg.NetBSD.org/src/rev/14f33b03fa1d
branches: trunk
changeset: 535040:14f33b03fa1d
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Aug 09 02:04:03 2002 +0000
description:
revoke root priv earlier. check fd_set overrun (and die if overrun).
avoid using runtime-generated printf format string. from xs%kittenz.org@localhost
diffstat:
usr.sbin/mtrace/mtrace.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diffs (74 lines):
diff -r 98eea8d47112 -r 14f33b03fa1d usr.sbin/mtrace/mtrace.c
--- a/usr.sbin/mtrace/mtrace.c Fri Aug 09 00:21:22 2002 +0000
+++ b/usr.sbin/mtrace/mtrace.c Fri Aug 09 02:04:03 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mtrace.c,v 1.20 2002/07/14 01:10:56 wiz Exp $ */
+/* $NetBSD: mtrace.c,v 1.21 2002/08/09 02:04:03 itojun Exp $ */
/*
* mtrace.c
@@ -52,7 +52,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mtrace.c,v 1.20 2002/07/14 01:10:56 wiz Exp $");
+__RCSID("$NetBSD: mtrace.c,v 1.21 2002/08/09 02:04:03 itojun Exp $");
#endif
#include <sys/types.h>
@@ -463,6 +463,8 @@
*/
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;
@@ -631,8 +633,6 @@
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);
@@ -1163,6 +1163,9 @@
fprintf(stderr, "mtrace: must be root\n");
exit(1);
}
+ init_igmp();
+ if (setuid(getuid()) == -1)
+ log(LOG_ERR, errno, "setuid");
argv++, argc--;
if (argc == 0) goto usage;
@@ -1300,8 +1303,6 @@
exit(1);
}
- init_igmp();
-
/*
* Set useful defaults for as many parameters as possible.
*/
@@ -1682,17 +1683,13 @@
log(int severity, int syserr, const 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);
- format = fmt;
+ if (severity == LOG_WARNING) fprintf(stderr, "warning - ");
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
Home |
Main Index |
Thread Index |
Old Index