REQUIRE(na->family == AF_INET || na->family == AF_INET6);
isc_buffer_init(&b, bdata, sizeof(bdata));
- isc_buffer_copyregion(&b, &inst->prefix);
+ RETERR(isc_buffer_copyregion(&b, &inst->prefix));
isc_buffer_init(&addrb, addrbdata, sizeof(addrbdata));
RETERR(isc_netaddr_totext(na, &addrb));
*/
isc_buffer_peekuint8(&addrb, &c);
if (c == ':') {
+ if (isc_buffer_availablelength(&b) == 0) {
+ return ISC_R_NOSPACE;
+ }
isc_buffer_putuint8(&b, '0');
}
isc_buffer_forward(&addrb, isc_buffer_usedlength(&addrb) - 1);
isc_buffer_peekuint8(&addrb, &c);
if (c == ':') {
+ if (isc_buffer_availablelength(&b) == 0) {
+ return ISC_R_NOSPACE;
+ }
isc_buffer_putuint8(&addrb, '0');
}
}
isc_buffer_usedregion(&addrb, &addrr);
- isc_buffer_copyregion(&b, &addrr);
+ RETERR(isc_buffer_copyregion(&b, &addrr));
/*
* Do not attempt to replace anything in the prefix
isc_buffer_init(&b, bdata, sizeof(bdata));
dns_name_totext(&label, DNS_NAME_OMITFINALDOT, &b);
+
+ /*
+ * Buffer is `DNS_NAME_FORMATSIZE` which is the maximum length of
+ * `dns_name_totext()` can put in there, plus one byte which we're
+ * setting here. So we know there is at least one remaining byte in the
+ * buffer.
+ */
isc_buffer_putuint8(&b, 0);
if (strncmp((const char *)inst->prefix.base, isc_buffer_base(&b),
inst->prefix.length) != 0)