summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMoritz Jodeit <moritz@cvs.openbsd.org>2005-04-19 17:15:54 +0000
committerMoritz Jodeit <moritz@cvs.openbsd.org>2005-04-19 17:15:54 +0000
commitf58a9436f2c5c263a756964e7391dc167b8210c0 (patch)
tree3e9cbc6bed3078b06f71b059fbadf4d9df98287b /usr.sbin
parentbba2b6205529743303c55f5e552e55f29c13b5f7 (diff)
fix more cases of snprintf() returning -1. ok cloder@ niallo@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bind/lib/dns/rdata/generic/soa_6.c7
-rw-r--r--usr.sbin/bind/lib/dns/ttl.c10
-rw-r--r--usr.sbin/bind/lib/lwres/lwinetntop.c6
3 files changed, 13 insertions, 10 deletions
diff --git a/usr.sbin/bind/lib/dns/rdata/generic/soa_6.c b/usr.sbin/bind/lib/dns/rdata/generic/soa_6.c
index ecbd87e7923..1d62c9f5b6b 100644
--- a/usr.sbin/bind/lib/dns/rdata/generic/soa_6.c
+++ b/usr.sbin/bind/lib/dns/rdata/generic/soa_6.c
@@ -130,14 +130,15 @@ totext_soa(ARGS_TOTEXT) {
for (i = 0; i < 5; i++) {
char buf[sizeof("2147483647")];
unsigned long num;
- unsigned int numlen;
+ int numlen;
num = uint32_fromregion(&dregion);
isc_region_consume(&dregion, 4);
numlen = snprintf(buf, sizeof(buf), "%lu", num);
- INSIST(numlen > 0 && numlen < sizeof("2147483647"));
+ INSIST(numlen != -1 && (size_t)numlen < sizeof(buf));
RETERR(str_totext(buf, target));
if (multiline && comment) {
- RETERR(str_totext(" ; " + numlen, target));
+ RETERR(str_totext(" ; " +
+ (unsigned int)numlen, target));
RETERR(str_totext(soa_fieldnames[i], target));
/* Print times in week/day/hour/minute/second form */
if (i >= 1) {
diff --git a/usr.sbin/bind/lib/dns/ttl.c b/usr.sbin/bind/lib/dns/ttl.c
index 849f10f2ad1..003703aad21 100644
--- a/usr.sbin/bind/lib/dns/ttl.c
+++ b/usr.sbin/bind/lib/dns/ttl.c
@@ -51,7 +51,7 @@ ttlfmt(unsigned int t, const char *s, isc_boolean_t verbose,
isc_boolean_t space, isc_buffer_t *target)
{
char tmp[60];
- size_t len;
+ int len;
isc_region_t region;
if (verbose)
@@ -62,12 +62,12 @@ ttlfmt(unsigned int t, const char *s, isc_boolean_t verbose,
else
len = snprintf(tmp, sizeof(tmp), "%u%c", t, s[0]);
- INSIST(len + 1 <= sizeof(tmp));
+ INSIST(len != -1 && (size_t)len + 1 <= sizeof(tmp));
isc_buffer_availableregion(target, &region);
- if (len > region.length)
+ if ((size_t)len > region.length)
return (ISC_R_NOSPACE);
- memcpy(region.base, tmp, len);
- isc_buffer_add(target, len);
+ memcpy(region.base, tmp, (size_t)len);
+ isc_buffer_add(target, (size_t)len);
return (ISC_R_SUCCESS);
}
diff --git a/usr.sbin/bind/lib/lwres/lwinetntop.c b/usr.sbin/bind/lib/lwres/lwinetntop.c
index 1d02defdf9a..311c5837ed9 100644
--- a/usr.sbin/bind/lib/lwres/lwinetntop.c
+++ b/usr.sbin/bind/lib/lwres/lwinetntop.c
@@ -84,10 +84,12 @@ static const char *
inet_ntop4(const unsigned char *src, char *dst, size_t size) {
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof("255.255.255.255")];
- size_t len;
+ int len;
len = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
- if (len >= size) {
+ if (len == -1)
+ return (NULL);
+ if ((size_t)len >= size) {
errno = ENOSPC;
return (NULL);
}