From 016b1a255a4619a8b85d12e8ef931c0dfa1e13ae Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 20 Aug 2001 12:56:45 +0000 Subject: Handle snprintf() returning -1. MFC after: 2 weeks --- sbin/route/route.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sbin/route') diff --git a/sbin/route/route.c b/sbin/route/route.c index 6501854..64a2e60 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -310,7 +310,7 @@ routename(sa) static char line[MAXHOSTNAMELEN + 1]; struct hostent *hp; static char domain[MAXHOSTNAMELEN + 1]; - static int first = 1; + static int first = 1, n; #ifdef NS char *ns_print(); #endif @@ -408,7 +408,8 @@ routename(sa) char *cpe = line + sizeof(line); while (++s < slim && cp < cpe) /* start with sa->sa_data */ - cp += snprintf(cp, cpe - cp, " %x", *s); + if ((n = snprintf(cp, cpe - cp, " %x", *s)) > 0) + cp += n; break; } } @@ -428,7 +429,7 @@ netname(sa) struct netent *np = 0; u_long net, mask; register u_long i; - int subnetshift; + int n, subnetshift; #ifdef NS char *ns_print(); #endif @@ -543,7 +544,8 @@ netname(sa) char *cpe = line + sizeof(line); while (s < slim && cp < cpe) - cp += snprintf(cp, cpe - cp, " %x", *s++); + if ((n = snprintf(cp, cpe - cp, " %x", *s++)) > 0) + cp += n; break; } } -- cgit v1.1