diff options
author | brian <brian@FreeBSD.org> | 2001-08-20 14:53:05 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-08-20 14:53:05 +0000 |
commit | 6820e8fb2d65a3b4d872ed5b1f5ae576f2dbcf59 (patch) | |
tree | 43eccc3994dfc9fbe0ce6fb8ae79fc9900a73306 | |
parent | 5bd90784a67de0a5e78e5bd967e2cd3d4f126cb7 (diff) | |
download | FreeBSD-src-6820e8fb2d65a3b4d872ed5b1f5ae576f2dbcf59.zip FreeBSD-src-6820e8fb2d65a3b4d872ed5b1f5ae576f2dbcf59.tar.gz |
Handle snprintf() returning < 0 (not just -1)
MFC after: 2 weeks
-rw-r--r-- | sbin/newfs/mkfs.c | 4 | ||||
-rw-r--r-- | sbin/ping6/ping6.c | 2 | ||||
-rw-r--r-- | sbin/route/route.c | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 84f0d9b..4772ae9 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -650,8 +650,8 @@ next: j = snprintf(tmpbuf, sizeof(tmpbuf), " %ld%s", fsbtodb(&sblock, cgsblock(&sblock, cylno)), cylno < (sblock.fs_ncg-1) ? "," : "" ); - if (j == -1) - j = 0; + if (j < 0) + tmpbuf[j = 0] = '\0'; if (i + j >= width) { printf("\n"); i = 0; diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 83f6682..790e921 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1353,7 +1353,7 @@ dnsdecode(sp, ep, base, buf, bufsiz) while (i-- > 0 && cp < ep) { l = snprintf(cresult, sizeof(cresult), isprint(*cp) ? "%c" : "\\%03o", *cp & 0xff); - if (l == -1 || l >= sizeof(cresult)) + if (l < 0 || l >= sizeof(cresult)) return NULL; if (strlcat(buf, cresult, bufsiz) >= bufsiz) return NULL; /*result overrun*/ diff --git a/sbin/route/route.c b/sbin/route/route.c index 64a2e60..dd23bc1 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -410,6 +410,8 @@ routename(sa) while (++s < slim && cp < cpe) /* start with sa->sa_data */ if ((n = snprintf(cp, cpe - cp, " %x", *s)) > 0) cp += n; + else + *cp = '\0'; break; } } @@ -546,6 +548,8 @@ netname(sa) while (s < slim && cp < cpe) if ((n = snprintf(cp, cpe - cp, " %x", *s++)) > 0) cp += n; + else + *cp = '\0'; break; } } |