diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-25 03:58:57 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-25 03:58:57 +0000 |
commit | dea1b65268ac6e279e7f4c479fb8566509353f66 (patch) | |
tree | 275b97e716919307468aa7a4bfecda5165fb15b4 /usr.bin | |
parent | 541d9e06d176f660decef027d507eb83054e126c (diff) |
handle < 0 and such better
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/atalk.c | 15 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 21 |
2 files changed, 17 insertions, 19 deletions
diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c index 8d502246ed2..22564a793ba 100644 --- a/usr.bin/netstat/atalk.c +++ b/usr.bin/netstat/atalk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atalk.c,v 1.8 2002/05/27 01:50:36 deraadt Exp $ */ +/* $OpenBSD: atalk.c,v 1.9 2002/07/25 03:58:56 deraadt 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.8 2002/05/27 01:50:36 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: atalk.c,v 1.9 2002/07/25 03:58:56 deraadt Exp $"; #endif #endif /* not lint */ @@ -232,17 +232,16 @@ atalk_print2(sa, mask, what) thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net & sat2->sat_addr.s_net; - n = snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 | (what & 8))); - if (n >= sizeof(buf)) + if ((n = snprintf(buf, sizeof(buf), "%s", + atalk_print(sa2, 1 | (what & 8)))) >= sizeof(buf)) n = sizeof(buf) - 1; - else if (n == -1) + else if (n < 0) 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; - l = snprintf(buf + n, sizeof(buf) - n, - "-%s", atalk_print(sa2, 1 | (what & 8))); - if (l >= sizeof(buf) - n) + if ((l = snprintf(buf + n, sizeof(buf) - n, + "-%s", atalk_print(sa2, 1 | (what & 8)))) >= sizeof(buf) - n) l = sizeof(buf) - n - 1; if (l > 0) n += l; diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 98740c86e5a..01ad68910d4 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.46 2002/05/27 01:50:36 deraadt Exp $ */ +/* $OpenBSD: route.c,v 1.47 2002/07/25 03:58:56 deraadt 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.46 2002/05/27 01:50:36 deraadt Exp $"; +static char *rcsid = "$OpenBSD: route.c,v 1.47 2002/07/25 03:58:56 deraadt Exp $"; #endif #endif /* not lint */ @@ -507,7 +507,7 @@ p_sockaddr(sa, mask, flags, width) workbuf + sizeof (workbuf) - cp, "%s%x", cplim, *lla); cplim = ":"; - if (n == -1) /* What else to do ? */ + if (n < 0) /* What else to do ? */ continue; if (n >= workbuf + sizeof (workbuf) - cp) n = workbuf + sizeof (workbuf) - cp - 1; @@ -535,23 +535,22 @@ p_sockaddr(sa, mask, flags, width) slim = sa->sa_len + (u_char *) sa; cplim = cp + sizeof(workbuf) - 6; - n = snprintf(cp, cplim - cp, "(%d)", sa->sa_family); - if (n >= cplim - cp) + if ((n = snprintf(cp, cplim - cp, "(%d)", sa->sa_family)) >= + cplim - cp) n = cplim - cp - 1; 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) + if ((n = snprintf(cp, workbuf + sizeof (workbuf) - cp, + " %02x", *s++)) >= workbuf + sizeof (workbuf) - cp) n = workbuf + sizeof (workbuf) - cp - 1; if (n > 0) cp += n; if (s < slim) { - n = snprintf(cp, + if ((n = snprintf(cp, workbuf + sizeof (workbuf) - cp, - "%02x", *s++); - if (n >= workbuf + sizeof (workbuf) - cp) + "%02x", *s++)) >= + workbuf + sizeof (workbuf) - cp) n = workbuf + sizeof (workbuf) - cp - 1; if (n > 0) cp += n; |