In rdataset_getheader() a cast of the raw buffer to dns_slabheader_t and
pointer arithmetics was used to get the start of the slabheader
structure. Use more correct offsetof(dns_slabheader_t, raw) to
calculate the correct start of the dns_slabheader_t from the flexible
member raw[].
static dns_slabheader_t *
rdataset_getheader(const dns_rdataset_t *rdataset) {
- dns_slabheader_t *header = (dns_slabheader_t *)rdataset->slab.raw;
- return header - 1;
+ uint8_t *rawbuf = rdataset->slab.raw;
+ return (dns_slabheader_t *)(rawbuf - offsetof(dns_slabheader_t, raw));
}
dns_slabtop_t *