Use the correct maximal compressed bit map buffer size

There are up to 256 windows in a NSEC/NSEC3 compressed bit
map of 32 + 2 octets each.

(cherry picked from commit e43e4bd20a)
This commit is contained in:
Mark Andrews 2026-03-26 13:10:45 +11:00 committed by Mark Andrews (GitLab job 7176352)
parent 5717e5756f
commit 7f485d3a63
2 changed files with 7 additions and 2 deletions

View file

@ -23,7 +23,12 @@
#include <dns/name.h>
#include <dns/types.h>
#define DNS_NSEC_BUFFERSIZE (DNS_NAME_MAXWIRE + 8192 + 512)
/*
* max compressed bitmap size:
* 256 windows * (window number + window length + bitmap (max 256 bits))
*/
#define DNS_NSEC_MAXCBMSIZE (256 * ((256 / 8) + 2))
#define DNS_NSEC_BUFFERSIZE (DNS_NAME_MAXWIRE + DNS_NSEC_MAXCBMSIZE)
ISC_LANG_BEGINDECLS

View file

@ -459,7 +459,7 @@ match_nsec3(const vctx_t *vctx, const dns_name_t *name,
const unsigned char types[8192], unsigned int maxtype,
const unsigned char *rawhash, size_t rhsize,
isc_result_t *vresult) {
unsigned char cbm[8244];
unsigned char cbm[DNS_NSEC_MAXCBMSIZE];
char namebuf[DNS_NAME_FORMATSIZE];
dns_rdata_nsec3_t nsec3;
isc_result_t result;