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

Merge branch '4798-cid-498025-and-cid-498031-overflowed-constant-integer_overflow' into 'main'

Closes #4798

See merge request isc-projects/bind9!9131
This commit is contained in:
Mark Andrews 2024-08-04 23:48:31 +00:00
commit 35d93624a5
2 changed files with 2 additions and 0 deletions

View file

@ -183,6 +183,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

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