diff --git a/lib/dns/rdata/generic/nsec3_50.c b/lib/dns/rdata/generic/nsec3_50.c index 95d04213ba..f9f356a576 100644 --- a/lib/dns/rdata/generic/nsec3_50.c +++ b/lib/dns/rdata/generic/nsec3_50.c @@ -212,7 +212,7 @@ fromwire_nsec3(ARGS_FROMWIRE) { hashlen = sr.base[0]; isc_region_consume(&sr, 1); - if (sr.length < hashlen) { + if (hashlen < 1 || sr.length < hashlen) { RETERR(DNS_R_FORMERR); } isc_region_consume(&sr, hashlen);