From 2ca452adf008ce324ce1491df7a83533ea86f982 Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Fri, 28 Feb 2025 16:25:13 +0100 Subject: [PATCH] - direct-rdata-storage, implement in qtest.c. - direct-rdata-storage, fix rdatas_equal in difffile.c, and nsec3_zone_trees_create. --- difffile.c | 10 ++++++++++ nsec3.c | 1 + tpkg/cutest/cutest_namedb.c | 1 + tpkg/cutest/qtest.c | 5 ++--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/difffile.c b/difffile.c index c447198a5..88f72d09d 100644 --- a/difffile.c +++ b/difffile.c @@ -335,6 +335,11 @@ rdatas_equal(const rr_type *rr1, const rr_type *rr2, uint16_t type, size_t offset = 0; const nsd_type_descriptor_type *descriptor; + if(rr1->rdlength != rr2->rdlength) { + *rdnum = 0; + *reason = "rr length different"; + return 0; + } assert(rr1->rdlength == rr2->rdlength); /** @@ -343,6 +348,11 @@ rdatas_equal(const rr_type *rr1, const rr_type *rr2, uint16_t type, **/ if (type == TYPE_SOA) { offset = 2 * sizeof(void*); + if(rr1->rdlength != offset + 20) { + *rdnum = 0; + *reason = "invalid SOA length"; + return 0; + } assert(rr1->rdlength == offset + 20); if (memcmp(rr1->rdata + offset, rr2->rdata + offset, 4) == 0) return 1; diff --git a/nsec3.c b/nsec3.c index 9278165d9..62267a1f7 100644 --- a/nsec3.c +++ b/nsec3.c @@ -661,6 +661,7 @@ prehash_zone_complete(struct namedb* db, struct zone* zone) zone->nsec3_last = NULL; return; } + nsec3_zone_trees_create(db->region, zone); nsec3_precompile_newparam(db, zone); } diff --git a/tpkg/cutest/cutest_namedb.c b/tpkg/cutest/cutest_namedb.c index 96de343c2..01baa5f48 100644 --- a/tpkg/cutest/cutest_namedb.c +++ b/tpkg/cutest/cutest_namedb.c @@ -657,6 +657,7 @@ parse_rr_str(struct zone *zone, char *input, struct parse_rr_state *state) length = strlen(input); string = malloc(length + 1 + ZONE_BLOCK_SIZE); + memset(string, 0, length + 1 + ZONE_BLOCK_SIZE); memcpy(string, input, length); string[length] = 0; diff --git a/tpkg/cutest/qtest.c b/tpkg/cutest/qtest.c index 11fa90a04..caebd7c5b 100644 --- a/tpkg/cutest/qtest.c +++ b/tpkg/cutest/qtest.c @@ -307,7 +307,7 @@ qread(char* qfile) static void buffer_spool_rr(buffer_type* output, rr_type* rr, int qsection) { - rrtype_descriptor_type *d = rrtype_descriptor_by_type(rr->type); + const nsd_type_descriptor_type *d = nsd_type_descriptor(rr->type); int result; const dname_type *owner = domain_dname(rr->owner); buffer_printf(output, "%s", dname_to_string(owner, NULL)); @@ -336,8 +336,7 @@ buffer_spool_rr(buffer_type* output, rr_type* rr, int qsection) result = print_rdata(output, d, rr); if (!result) { /* Some RDATA failed to print, so do unknown format. */ - result = rdata_atoms_to_unknown_string(output, d, - rr->rdata_count, rr->rdatas); + result = print_rdata(output, d, rr); if(!result) { buffer_printf(output, "rdata_atoms_to_unknown_string failed");