2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 01:59:26 +00:00

use get_uint16() to read count and rdlen

use the same macro defned for rdataslab.c to get count and
length values from raw slabs in qpzone.c.
This commit is contained in:
Evan Hunt 2025-08-17 13:59:05 -07:00 committed by Ondřej Surý
parent 04d6412558
commit 712ef31a0c
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41
3 changed files with 18 additions and 21 deletions

View File

@ -1111,12 +1111,11 @@ setnsec3parameters(dns_db_t *db, qpz_version_t *version) {
* Find an NSEC3PARAM with a supported algorithm.
*/
raw = dns_slabheader_raw(found);
count = raw[0] * 256 + raw[1]; /* count */
raw += DNS_RDATASET_LENGTH;
count = get_uint16(raw);
while (count-- > 0U) {
dns_rdata_t rdata = DNS_RDATA_INIT;
length = raw[0] * 256 + raw[1];
raw += DNS_RDATASET_LENGTH;
length = get_uint16(raw);
region.base = raw;
region.length = length;
raw += length;
@ -2617,14 +2616,12 @@ matchparams(dns_slabheader_t *header, qpz_search_t *search) {
REQUIRE(header->typepair == DNS_TYPEPAIR(dns_rdatatype_nsec3));
raw = (unsigned char *)header + sizeof(*header);
count = raw[0] * 256 + raw[1]; /* count */
raw += DNS_RDATASET_LENGTH;
count = get_uint16(raw);
while (count-- > 0) {
dns_rdata_t rdata = DNS_RDATA_INIT;
rdlen = raw[0] * 256 + raw[1];
raw += DNS_RDATASET_LENGTH;
rdlen = get_uint16(raw);
region.base = raw;
region.length = rdlen;
dns_rdata_fromregion(&rdata, search->qpdb->common.rdclass,

View File

@ -49,19 +49,6 @@
* When a slab is created, data records are sorted into DNSSEC order.
*/
#define peek_uint16(buffer) ({ ((uint16_t)*(buffer) << 8) | *((buffer) + 1); })
#define get_uint16(buffer) \
({ \
uint16_t __ret = peek_uint16(buffer); \
buffer += sizeof(uint16_t); \
__ret; \
})
#define put_uint16(buffer, val) \
({ \
*buffer++ = (val & 0xff00) >> 8; \
*buffer++ = (val & 0x00ff); \
})
static void
rdataset_disassociate(dns_rdataset_t *rdataset DNS__DB_FLARG);
static isc_result_t

View File

@ -57,3 +57,16 @@
#define ZEROTTL(header) \
((atomic_load_acquire(&(header)->attributes) & \
DNS_SLABHEADERATTR_ZEROTTL) != 0)
#define peek_uint16(buffer) ({ ((uint16_t)*(buffer) << 8) | *((buffer) + 1); })
#define get_uint16(buffer) \
({ \
uint16_t __ret = peek_uint16(buffer); \
buffer += sizeof(uint16_t); \
__ret; \
})
#define put_uint16(buffer, val) \
({ \
*buffer++ = (val & 0xff00) >> 8; \
*buffer++ = (val & 0x00ff); \
})