diff options
author | brian <brian@FreeBSD.org> | 2001-08-20 12:56:45 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-08-20 12:56:45 +0000 |
commit | 016b1a255a4619a8b85d12e8ef931c0dfa1e13ae (patch) | |
tree | b8663d7f77ab3499896e68cc38771d771c5b2f6f /sbin/route | |
parent | 110fc843a0e59e68be1a9d8d1a4bb0bcb152872b (diff) | |
download | FreeBSD-src-016b1a255a4619a8b85d12e8ef931c0dfa1e13ae.zip FreeBSD-src-016b1a255a4619a8b85d12e8ef931c0dfa1e13ae.tar.gz |
Handle snprintf() returning -1.
MFC after: 2 weeks
Diffstat (limited to 'sbin/route')
-rw-r--r-- | sbin/route/route.c | 10 |
1 files changed, 6 insertions, 4 deletions
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; } } |