summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2001-08-18 22:14:04 +0000
committerbrian <brian@cvs.openbsd.org>2001-08-18 22:14:04 +0000
commite7fdf13effc542c6b6d5730d91d7f57fe2456e4b (patch)
tree0b34dd57706314e57903c33bd83267cc88004e79 /usr.bin
parentababb07fe87c1e968713418ad764dfd7394d11bc (diff)
Handle snprintf returning -1
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/atalk.c12
-rw-r--r--usr.bin/netstat/route.c17
2 files changed, 19 insertions, 10 deletions
diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c
index 2a104fb0b88..7d452277bea 100644
--- a/usr.bin/netstat/atalk.c
+++ b/usr.bin/netstat/atalk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atalk.c,v 1.3 2001/01/29 01:58:13 niklas Exp $ */
+/* $OpenBSD: atalk.c,v 1.4 2001/08/18 22:14:03 brian Exp $ */
/* $NetBSD: atalk.c,v 1.2 1997/05/22 17:21:26 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from @(#)atalk.c 1.1 (Whistle) 6/6/96";
#else
-static char rcsid[] = "$OpenBSD: atalk.c,v 1.3 2001/01/29 01:58:13 niklas Exp $";
+static char rcsid[] = "$OpenBSD: atalk.c,v 1.4 2001/08/18 22:14:03 brian Exp $";
#endif
#endif /* not lint */
@@ -235,6 +235,8 @@ atalk_print2(sa, mask, what)
n = snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 | (what & 8)));
if (n >= sizeof(buf))
n = sizeof(buf) - 1;
+ else if (n == -1)
+ n = 0; /* What else can be done ? */
if (sat2->sat_addr.s_net != 0xFFFF) {
thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net |
~sat2->sat_addr.s_net;
@@ -242,14 +244,16 @@ atalk_print2(sa, mask, what)
"-%s", atalk_print(sa2, 1 | (what & 8)));
if (l >= sizeof(buf) - n)
l = sizeof(buf) - n - 1;
- n += l;
+ if (l > 0)
+ n += l;
}
if (what & 2) {
l = snprintf(buf + n, sizeof(buf) - n, ".%s",
atalk_print(sa, what & (~1)));
if (l >= sizeof(buf) - n)
l = sizeof(buf) - n - 1;
- n += l;
+ if (l > 0)
+ n += l;
}
return (buf);
}
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 1468a0e03cd..4952d7f76f5 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.40 2001/06/25 00:41:39 niklas Exp $ */
+/* $OpenBSD: route.c,v 1.41 2001/08/18 22:14:03 brian Exp $ */
/* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
-static char *rcsid = "$OpenBSD: route.c,v 1.40 2001/06/25 00:41:39 niklas Exp $";
+static char *rcsid = "$OpenBSD: route.c,v 1.41 2001/08/18 22:14:03 brian Exp $";
#endif
#endif /* not lint */
@@ -506,10 +506,12 @@ p_sockaddr(sa, mask, flags, width)
n = snprintf(cp,
workbuf + sizeof (workbuf) - cp,
"%s%x", cplim, *lla);
+ cplim = ":";
+ if (n == -1) /* What else to do ? */
+ continue;
if (n >= workbuf + sizeof (workbuf) - cp)
n = workbuf + sizeof (workbuf) - cp - 1;
cp += n;
- cplim = ":";
}
cp = workbuf;
break;
@@ -536,20 +538,23 @@ p_sockaddr(sa, mask, flags, width)
n = snprintf(cp, cplim - cp, "(%d)", sa->sa_family);
if (n >= cplim - cp)
n = cplim - cp - 1;
- cp += n;
+ if (n > 0)
+ cp += n;
while (s < slim && cp < cplim) {
n = snprintf(cp, workbuf + sizeof (workbuf) - cp,
" %02x", *s++);
if (n >= workbuf + sizeof (workbuf) - cp)
n = workbuf + sizeof (workbuf) - cp - 1;
- cp += n;
+ if (n > 0)
+ cp += n;
if (s < slim) {
n = snprintf(cp,
workbuf + sizeof (workbuf) - cp,
"%02x", *s++);
if (n >= workbuf + sizeof (workbuf) - cp)
n = workbuf + sizeof (workbuf) - cp - 1;
- cp += n;
+ if (n > 0)
+ cp += n;
}
}
cp = workbuf;