summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-08-08 00:28:10 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-08-08 00:28:10 +0000
commit5d1613f1bd5ec819a17776b23b670b9303d8128f (patch)
tree6aeabb1132fee4c818900bdf38992b50c8a521be
parent026c644c9bea73edcaadbbacd6696188d77d6876 (diff)
don't use dynamically-generated printf format string. more picky
about gethostby* result. check fd_set overrun. from xs@kittenz.org
-rw-r--r--usr.sbin/mrinfo/mrinfo.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.sbin/mrinfo/mrinfo.c b/usr.sbin/mrinfo/mrinfo.c
index a856522af37..136d549cea4 100644
--- a/usr.sbin/mrinfo/mrinfo.c
+++ b/usr.sbin/mrinfo/mrinfo.c
@@ -140,7 +140,6 @@ void
log(int severity, int syserr, char *format, ...)
{
va_list ap;
- char fmt[100];
switch (debug) {
case 0:
@@ -153,12 +152,10 @@ log(int severity, int syserr, char *format, ...)
if (severity > LOG_INFO)
return;
default:
- fmt[0] = '\0';
if (severity == LOG_WARNING)
- strcat(fmt, "warning - ");
- strncat(fmt, format, 80);
+ fprintf(stderr, "warning - ");
va_start(ap, format);
- vfprintf(stderr, fmt, ap);
+ vfprintf(stderr, format, ap);
va_end(ap);
if (syserr == 0)
fputc('\n', stderr);
@@ -386,7 +383,7 @@ main(argc, argv)
} else
hp = gethostbyname(host);
- if (hp == NULL) {
+ if (hp == NULL || hp->h_length != sizeof(target_addr)) {
fprintf(stderr, "mrinfo: %s: no such host\n", argv[0]);
exit(1);
}
@@ -442,6 +439,8 @@ main(argc, argv)
int ipdatalen, iphdrlen, igmpdatalen;
FD_ZERO(&fds);
+ if (igmp_socket >= FD_SETSIZE)
+ log(LOG_ERR, 0, "descriptor too big");
FD_SET(igmp_socket, &fds);
gettimeofday(&now, 0);