[9.18] fix: dev: CID 498025 and CID 498031: Overflowed constant INTEGER_OVERFLOW

Add INSIST to fail if the multiplication would cause the variables to overflow.

Closes #4798

Backport of MR !9131

Merge branch 'backport-4798-cid-498025-and-cid-498031-overflowed-constant-integer_overflow-9.18' into 'bind-9.18'

See merge request isc-projects/bind9!9230
This commit is contained in:
Mark Andrews 2024-08-05 01:38:09 +00:00
commit bbdd888b8e
2 changed files with 2 additions and 0 deletions

View file

@ -185,6 +185,7 @@ retry:
result = dns_rdata_totext(rdata, NULL, b);
if (result == ISC_R_NOSPACE) {
isc_buffer_free(&b);
INSIST(bufsize <= (UINT_MAX / 2));
bufsize *= 2;
goto retry;
}

View file

@ -204,6 +204,7 @@ printrdata(dns_rdata_t *rdata) {
check_result(result, "dns_rdata_totext");
}
isc_buffer_free(&b);
INSIST(size <= (UINT_MAX / 2));
size *= 2;
}
}