Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/mrouted Revert previous change. Remove s parameter...
details: https://anonhg.NetBSD.org/src/rev/bf6ed7a53c2a
branches: trunk
changeset: 547311:bf6ed7a53c2a
user: dsl <dsl%NetBSD.org@localhost>
date: Fri May 16 22:59:50 2003 +0000
description:
Revert previous change. Remove s parameter from teh function and rotate
the result through a fixed set of strings instead.
There never was a possibility of a buffer overrun in inet_fmt{s}().
Fix an actual buffer overrun in a scanf() call.
diffstat:
usr.sbin/mrouted/cfparse.y | 50 ++++-----
usr.sbin/mrouted/config.c | 10 +-
usr.sbin/mrouted/defs.h | 13 +-
usr.sbin/mrouted/igmp.c | 22 ++--
usr.sbin/mrouted/inet.c | 46 +++++---
usr.sbin/mrouted/kern.c | 12 +-
usr.sbin/mrouted/prune.c | 243 ++++++++++++++++++++++----------------------
usr.sbin/mrouted/route.c | 34 +++---
usr.sbin/mrouted/rsrr.c | 12 +-
usr.sbin/mrouted/vif.c | 63 +++++------
10 files changed, 250 insertions(+), 255 deletions(-)
diffs (truncated from 1467 to 300 lines):
diff -r af9ed27c82f0 -r bf6ed7a53c2a usr.sbin/mrouted/cfparse.y
--- a/usr.sbin/mrouted/cfparse.y Fri May 16 22:40:56 2003 +0000
+++ b/usr.sbin/mrouted/cfparse.y Fri May 16 22:59:50 2003 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cfparse.y,v 1.12 2003/05/16 18:10:38 itojun Exp $ */
+/* $NetBSD: cfparse.y,v 1.13 2003/05/16 22:59:50 dsl Exp $ */
/*
* Configuration file parser for mrouted.
@@ -123,7 +123,7 @@
if (vifi == numvifs)
fatal("%s is not a configured interface",
- inet_fmt($2,s1, sizeof(s1)));
+ inet_fmt($2));
}
ifmods
@@ -138,18 +138,18 @@
ifr = ifconfaddr(&ifc, $2);
if (ifr == 0)
fatal("Tunnel local address %s is not mine",
- inet_fmt($2, s1, sizeof(s1)));
+ inet_fmt($2));
strncpy(ffr.ifr_name, ifr->ifr_name, IFNAMSIZ);
if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ffr)<0)
fatal("ioctl SIOCGIFFLAGS on %s",ffr.ifr_name);
if (ffr.ifr_flags & IFF_LOOPBACK)
fatal("Tunnel local address %s is a loopback interface",
- inet_fmt($2, s1, sizeof(s1)));
+ inet_fmt($2));
if (ifconfaddr(&ifc, $3) != 0)
fatal("Tunnel remote address %s is one of mine",
- inet_fmt($3, s1, sizeof(s1)));
+ inet_fmt($3));
for (vifi = 0, v = uvifs;
vifi < numvifs;
@@ -157,11 +157,11 @@
if (v->uv_flags & VIFF_TUNNEL) {
if ($3 == v->uv_rmt_addr)
fatal("Duplicate tunnel to %s",
- inet_fmt($3, s1, sizeof(s1)));
+ inet_fmt($3));
} else if (!(v->uv_flags & VIFF_DISABLED)) {
if (($3 & v->uv_subnetmask) == v->uv_subnet)
fatal("Unnecessary tunnel to %s",
- inet_fmt($3,s1, sizeof(s1)));
+ inet_fmt($3));
}
if (numvifs == MAXVIFS)
@@ -192,8 +192,8 @@
{
logit(LOG_INFO, 0,
"installing tunnel from %s to %s as vif #%u - rate=%d",
- inet_fmt($2, s1, sizeof(s1)),
- inet_fmt($3, s2, sizeof(s2)),
+ inet_fmt($2),
+ inet_fmt($3),
numvifs, v->uv_rate_limit);
++numvifs;
@@ -278,7 +278,7 @@
ph->pa_subnetbcast = ph->pa_subnet | ~ph->pa_subnetmask;
if ($2.addr & ~ph->pa_subnetmask)
warn("Extra subnet %s/%d has host bits set",
- inet_fmt($2.addr,s1, sizeof(s1)), $2.mask);
+ inet_fmt($2.addr), $2.mask);
ph->pa_next = v->uv_addrs;
v->uv_addrs = ph;
@@ -328,7 +328,7 @@
v_acl->acl_addr = $2.addr & v_acl->acl_mask;
if ($2.addr & ~v_acl->acl_mask)
warn("Boundary spec %s/%d has host bits set",
- inet_fmt($2.addr,s1, sizeof(s1)),$2.mask);
+ inet_fmt($2.addr),$2.mask);
v_acl->acl_next = v->uv_acl;
v->uv_acl = v_acl;
@@ -381,7 +381,7 @@
if ((ntohl($1.addr) & 0xff000000) != 0xef000000) {
fatal("Boundaries must be 239.x.x.x, not %s/%d",
- inet_fmt($1.addr, s1, sizeof(s1)), $1.mask);
+ inet_fmt($1.addr), $1.mask);
}
$$ = $1;
@@ -475,6 +475,7 @@
int n;
u_int32_t addr;
char *q;
+ char c;
if ((q = next_word()) == NULL) {
return 0;
@@ -516,26 +517,21 @@
yylval.num = 0;
return BOOLEAN;
}
- if (sscanf(q,"%[.0-9]/%d%c",s1,&n,s2) == 2) {
- if ((addr = inet_parse(s1)) != 0xffffffff) {
- yylval.addrmask.mask = n;
- yylval.addrmask.addr = addr;
- return ADDRMASK;
- }
- /* fall through to returning STRING */
+ if ((addr = inet_parse(q, &n)) != 0xffffffff) {
+ yylval.addrmask.mask = n;
+ yylval.addrmask.addr = addr;
+ return ADDRMASK;
}
- if (sscanf(q,"%[.0-9]%c",s1,s2) == 1) {
- if ((addr = inet_parse(s1)) != 0xffffffff &&
- inet_valid_host(addr)) {
- yylval.addr = addr;
- return ADDR;
- }
+ if ((addr = inet_parse(q,0)) != 0xffffffff &&
+ inet_valid_host(addr)) {
+ yylval.addr = addr;
+ return ADDR;
}
- if (sscanf(q,"0x%8x%c",&n,s1) == 1) {
+ if (sscanf(q,"0x%8x%c",&n,&c) == 1) {
yylval.addr = n;
return ADDR;
}
- if (sscanf(q,"%d%c",&n,s1) == 1) {
+ if (sscanf(q,"%d%c",&n,&c) == 1) {
yylval.num = n;
return NUMBER;
}
diff -r af9ed27c82f0 -r bf6ed7a53c2a usr.sbin/mrouted/config.c
--- a/usr.sbin/mrouted/config.c Fri May 16 22:40:56 2003 +0000
+++ b/usr.sbin/mrouted/config.c Fri May 16 22:59:50 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.c,v 1.12 2003/05/16 18:10:38 itojun Exp $ */
+/* $NetBSD: config.c,v 1.13 2003/05/16 22:59:50 dsl Exp $ */
/*
* The mrouted program is covered by the license in the accompanying file
@@ -59,8 +59,8 @@
addr == (subnet | ~mask)) {
logit(LOG_WARNING, 0,
"ignoring %s, has invalid address (%s) and/or mask (%s)",
- ifa->ifa_name, inet_fmt(addr, s1, sizeof(s1)),
- inet_fmt(mask, s2, sizeof(s2)));
+ ifa->ifa_name, inet_fmt(addr),
+ inet_fmt(mask));
continue;
}
@@ -103,8 +103,8 @@
v->uv_addrs = NULL;
logit(LOG_INFO,0,"installing %s (%s on subnet %s) as vif #%u - rate=%d",
- v->uv_name, inet_fmt(addr, s1, sizeof(s1)),
- inet_fmts(subnet, mask, s2, sizeof(s2)),
+ v->uv_name, inet_fmt(addr),
+ inet_fmts(subnet, mask),
numvifs, v->uv_rate_limit);
++numvifs;
diff -r af9ed27c82f0 -r bf6ed7a53c2a usr.sbin/mrouted/defs.h
--- a/usr.sbin/mrouted/defs.h Fri May 16 22:40:56 2003 +0000
+++ b/usr.sbin/mrouted/defs.h Fri May 16 22:59:50 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.12 2003/05/16 18:10:38 itojun Exp $ */
+/* $NetBSD: defs.h,v 1.13 2003/05/16 22:59:50 dsl Exp $ */
/*
* The mrouted program is covered by the license in the accompanying file
@@ -126,11 +126,6 @@
extern int udp_socket;
extern int vifs_with_neighbors;
-extern char s1[19];
-extern char s2[19];
-extern char s3[19];
-extern char s4[19];
-
#if !(defined(BSD) && (BSD >= 199103))
extern int errno;
extern int sys_nerr;
@@ -226,9 +221,9 @@
extern int inet_valid_host(u_int32_t naddr);
extern int inet_valid_mask(u_int32_t mask);
extern int inet_valid_subnet(u_int32_t nsubnet, u_int32_t nmask);
-extern char * inet_fmt(u_int32_t addr, char *s, size_t);
-extern char * inet_fmts(u_int32_t addr, u_int32_t mask, char *s, size_t);
-extern u_int32_t inet_parse(char *s);
+extern char * inet_fmt(u_int32_t addr);
+extern char * inet_fmts(u_int32_t addr, u_int32_t mask);
+extern u_int32_t inet_parse(char *s, int *);
extern int inet_cksum(u_short *addr, u_int len);
/* prune.c */
diff -r af9ed27c82f0 -r bf6ed7a53c2a usr.sbin/mrouted/igmp.c
--- a/usr.sbin/mrouted/igmp.c Fri May 16 22:40:56 2003 +0000
+++ b/usr.sbin/mrouted/igmp.c Fri May 16 22:59:50 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: igmp.c,v 1.11 2003/05/16 18:10:38 itojun Exp $ */
+/* $NetBSD: igmp.c,v 1.12 2003/05/16 22:59:50 dsl Exp $ */
/*
* The mrouted program is covered by the license in the accompanying file
@@ -156,7 +156,7 @@
if (iphdrlen + ipdatalen != recvlen) {
logit(LOG_WARNING, 0,
"received packet from %s shorter (%u bytes) than hdr+data length (%u+%u)",
- inet_fmt(src, s1, sizeof(s1)), recvlen, iphdrlen, ipdatalen);
+ inet_fmt(src), recvlen, iphdrlen, ipdatalen);
return;
}
@@ -166,13 +166,13 @@
if (igmpdatalen < 0) {
logit(LOG_WARNING, 0,
"received IP data field too short (%u bytes) for IGMP, from %s",
- ipdatalen, inet_fmt(src, s1, sizeof(s1)));
+ ipdatalen, inet_fmt(src));
return;
}
logit(LOG_DEBUG, 0, "RECV %s from %-15s to %s",
packet_kind(igmp->igmp_type, igmp->igmp_code),
- inet_fmt(src, s1, sizeof(s1)), inet_fmt(dst, s2, sizeof(s2)));
+ inet_fmt(src), inet_fmt(dst));
switch (igmp->igmp_type) {
@@ -245,8 +245,8 @@
default:
logit(LOG_INFO, 0,
"ignoring unknown DVMRP message code %u from %s to %s",
- igmp->igmp_code, inet_fmt(src, s1, sizeof(s1)),
- inet_fmt(dst, s2, sizeof(s2)));
+ igmp->igmp_code, inet_fmt(src),
+ inet_fmt(dst));
return;
}
@@ -264,8 +264,8 @@
default:
logit(LOG_INFO, 0,
"ignoring unknown IGMP message type %x from %s to %s",
- igmp->igmp_type, inet_fmt(src, s1, sizeof(s1)),
- inet_fmt(dst, s2, sizeof(s2)));
+ igmp->igmp_type, inet_fmt(src),
+ inet_fmt(dst));
return;
}
}
@@ -342,13 +342,13 @@
else
logit(igmp_log_level(type, code), errno,
"sendto to %s on %s",
- inet_fmt(dst, s1, sizeof(s1)), inet_fmt(src, s2, sizeof(s2)));
+ inet_fmt(dst), inet_fmt(src));
}
if (setloop)
k_set_loop(FALSE);
logit(LOG_DEBUG, 0, "SENT %s from %-15s to %s",
- packet_kind(type, code), inet_fmt(src, s1, sizeof(s1)),
- inet_fmt(dst, s2, sizeof(s2)));
+ packet_kind(type, code), inet_fmt(src),
+ inet_fmt(dst));
}
diff -r af9ed27c82f0 -r bf6ed7a53c2a usr.sbin/mrouted/inet.c
--- a/usr.sbin/mrouted/inet.c Fri May 16 22:40:56 2003 +0000
+++ b/usr.sbin/mrouted/inet.c Fri May 16 22:59:50 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inet.c,v 1.10 2003/05/16 18:10:38 itojun Exp $ */
+/* $NetBSD: inet.c,v 1.11 2003/05/16 22:59:50 dsl Exp $ */
/*
* The mrouted program is covered by the license in the accompanying file
@@ -13,13 +13,11 @@
#include "defs.h"
-/*
- * Exported variables.
- */
-char s1[19]; /* buffers to hold the string representations */
-char s2[19]; /* of IP addresses, to be passed to inet_fmt() */
-char s3[19]; /* or inet_fmts(). */
-char s4[19];
+/* buffers to hold the string representations */
+/* of IP addresses, returned by inet_fmt{s}() */
+#define SS_MASK ((1 << 3) - 1)
+static char ss[SS_MASK + 1][32];
Home |
Main Index |
Thread Index |
Old Index