From b8e07a0b5aed51828af72af2a8d58b090088725d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 17 Dec 2025 10:01:06 +0100 Subject: [PATCH] Use offsetof() instead of pointer arithmetics to get slabheader 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[]. --- lib/dns/rdataslab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index c56cd3b03b..64e955cad4 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -801,8 +801,8 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) { 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 *