summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-08-20 12:56:45 +0000
committerbrian <brian@FreeBSD.org>2001-08-20 12:56:45 +0000
commit016b1a255a4619a8b85d12e8ef931c0dfa1e13ae (patch)
treeb8663d7f77ab3499896e68cc38771d771c5b2f6f /sbin
parent110fc843a0e59e68be1a9d8d1a4bb0bcb152872b (diff)
downloadFreeBSD-src-016b1a255a4619a8b85d12e8ef931c0dfa1e13ae.zip
FreeBSD-src-016b1a255a4619a8b85d12e8ef931c0dfa1e13ae.tar.gz
Handle snprintf() returning -1.
MFC after: 2 weeks
Diffstat (limited to 'sbin')
-rw-r--r--sbin/newfs/mkfs.c2
-rw-r--r--sbin/ping6/ping6.c2
-rw-r--r--sbin/route/route.c10
3 files changed, 9 insertions, 5 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 19049ee..84f0d9b 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -650,6 +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 (i + j >= width) {
printf("\n");
i = 0;
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 1259b4a..83f6682 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 >= sizeof(cresult))
+ if (l == -1 || 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 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;
}
}
OpenPOWER on IntegriCloud