]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
use get_uint16() to read count and rdlen
authorEvan Hunt <each@isc.org>
Sun, 17 Aug 2025 20:59:05 +0000 (13:59 -0700)
committerOndřej Surý <ondrej@isc.org>
Mon, 18 Aug 2025 10:36:47 +0000 (12:36 +0200)
use the same macro defned for rdataslab.c to get count and
length values from raw slabs in qpzone.c.

lib/dns/qpzone.c
lib/dns/rdataslab.c
lib/dns/rdataslab_p.h

index e2cc089c75764e87be9630667b2acb002116b20c..3f2124546bd8dd65af1efb0cc8e26ac25c5f8e3d 100644 (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,
index e2d054a5881a2a4a8df9431e9dc846de66637c6d..48fd9962d1d11b2e0a213abcd7a162f319a62658 100644 (file)
  * 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
index e3b4fbb573db93912341b82f82e26bc3ba43e8aa..2fed31a2f0420dfe9b5f93adf1def1001f5a45b3 100644 (file)
 #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);      \
+       })