diff --git a/lib/dns/rdata/generic/nsec3_50.c b/lib/dns/rdata/generic/nsec3_50.c index 027f888a27..e1eab66d5a 100644 --- a/lib/dns/rdata/generic/nsec3_50.c +++ b/lib/dns/rdata/generic/nsec3_50.c @@ -302,6 +302,7 @@ tostruct_nsec3(ARGS_TOSTRUCT) { nsec3->iterations = uint16_consume_fromregion(®ion); nsec3->salt_length = uint8_consume_fromregion(®ion); + INSIST(nsec3->salt_length <= region.length); nsec3->salt = mem_maybedup(mctx, region.base, nsec3->salt_length); if (nsec3->salt == NULL) { return (ISC_R_NOMEMORY); @@ -309,6 +310,7 @@ tostruct_nsec3(ARGS_TOSTRUCT) { isc_region_consume(®ion, nsec3->salt_length); nsec3->next_length = uint8_consume_fromregion(®ion); + INSIST(nsec3->next_length <= region.length); nsec3->next = mem_maybedup(mctx, region.base, nsec3->next_length); if (nsec3->next == NULL) { goto cleanup;