]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Prevent overflow of bufsize
authorMark Andrews <marka@isc.org>
Tue, 9 Jul 2024 01:55:46 +0000 (11:55 +1000)
committerMark Andrews <marka@isc.org>
Sat, 3 Aug 2024 03:39:26 +0000 (03:39 +0000)
If bufsize overflows we will have an infinite loop.  In practice
this will not happen unless we have made a coding error.  Add an
INSIST to detect this condition.

    181retry:
    182        isc_buffer_allocate(mctx, &b, bufsize);
    183        result = dns_rdata_totext(rdata, NULL, b);
    184        if (result == ISC_R_NOSPACE) {
    185                isc_buffer_free(&b);

    CID 498031: (#1 of 1): Overflowed constant (INTEGER_OVERFLOW)
    overflow_const: Expression bufsize, which is equal to 0, overflows
    the type that receives it, an unsigned integer 32 bits wide.
    186                bufsize *= 2;
    187                goto retry;
    188        }

bin/dig/host.c

index ccc3ad60b68bc24b8ebe0f2cd7f8ee35e15ee291..6710c981f16e448186788663a48f0271c0174d23 100644 (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;
        }