mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-11 09:50:12 +00:00
Handle snprintf() returning < 0 (not just -1)
MFC after: 2 weeks
This commit is contained in:
parent
cbe1d3b630
commit
9cfe90fe1f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81980
@ -650,8 +650,8 @@ mkfs(pp, fsys, fi, fo)
|
||||
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;
|
||||
|
@ -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*/
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user