mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-04 08:35:31 +00:00
silence a warning about unsafe snprintf() call
This commit is contained in:
@@ -713,12 +713,12 @@ ip2name(const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix,
|
|||||||
(tgt_ip->w[3] >> 8) & 0xffU,
|
(tgt_ip->w[3] >> 8) & 0xffU,
|
||||||
(tgt_ip->w[3] >> 16) & 0xffU,
|
(tgt_ip->w[3] >> 16) & 0xffU,
|
||||||
(tgt_ip->w[3] >> 24) & 0xffU);
|
(tgt_ip->w[3] >> 24) & 0xffU);
|
||||||
if (len < 0 || len > (int)sizeof(str)) {
|
if (len < 0 || (size_t)len >= sizeof(str)) {
|
||||||
return (ISC_R_FAILURE);
|
return (ISC_R_FAILURE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
len = snprintf(str, sizeof(str), "%d", tgt_prefix);
|
len = snprintf(str, sizeof(str), "%d", tgt_prefix);
|
||||||
if (len == -1) {
|
if (len < 0 || (size_t)len >= sizeof(str)) {
|
||||||
return (ISC_R_FAILURE);
|
return (ISC_R_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,15 +753,19 @@ ip2name(const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (n = 0; n <= 7; ++n) {
|
for (n = 0; n <= 7; ++n) {
|
||||||
INSIST(len < (int)sizeof(str));
|
INSIST(len > 0 && (size_t)len < sizeof(str));
|
||||||
if (n == best_first) {
|
if (n == best_first) {
|
||||||
len += snprintf(str + len, sizeof(str) - len,
|
i = snprintf(str + len, sizeof(str) - len,
|
||||||
".zz");
|
".zz");
|
||||||
n += best_len - 1;
|
n += best_len - 1;
|
||||||
} else {
|
} else {
|
||||||
len += snprintf(str + len, sizeof(str) - len,
|
i = snprintf(str + len, sizeof(str) - len,
|
||||||
".%x", w[n]);
|
".%x", w[n]);
|
||||||
}
|
}
|
||||||
|
if (i < 0 || (size_t)i >= (size_t)(sizeof(str) - len)) {
|
||||||
|
return (ISC_R_FAILURE);
|
||||||
|
}
|
||||||
|
len += i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user