Compare commits

...

9 Commits

Author SHA1 Message Date
Evan Hunt
933137927a fixup! Add a unit test for wildcards in a zone 2025-02-14 15:43:32 -08:00
Evan Hunt
fbd7b7d40c add a REQUIRE that foundname != name in dns_db_find()
in dns_db_find() and _findext(), if foundname was set to the same
value as name, then the query name could be updated during processing,
leading to inconsistent results.
2025-02-14 12:46:38 -08:00
Evan Hunt
43709d3190 fixup! Add a unit test for wildcards in a zone 2025-02-14 12:46:31 -08:00
Ondřej Surý
5542aa8220 Add a unit test for wildcards in a zone
Test that a wildcard added to a zone database is matched
correctly afterward.
2025-02-14 12:45:01 -08:00
Ondřej Surý
4153275080 Add unit test to check how cname_and_others() work 2025-02-14 12:39:13 +01:00
Ondřej Surý
60d476ffc5 Add more unit tests that test qpzonedb addrdataset
Add more unit testing for the dns_db_addrdataset() testing the various
flags and adding multiple records with same content.  This also adds a
small framework to write these tests in more efficient manner.
2025-02-14 11:07:32 +01:00
Ondřej Surý
426baf2cd7 Remove DNS_DBADD_FORCE usage in qpzone.c
The subtractrdataset() in qpzone.c was adding DNS_DBADD_FORCE flag to
the add() function, but since the zone database has no concept of
"trust", it was just confusing no-op flag.  Remove it.
2025-02-14 11:07:32 +01:00
Ondřej Surý
f5dd4d93aa Fix DNS_DBADD_EXACT flag
The DNS_DBADD_EXACT flag was practically no-op, fix the code that checks
whether there's no intersection between new and old headers.  The old
code was non-functional.
2025-02-14 11:07:32 +01:00
Ondřej Surý
1f2f7ee255 Always initialize the rdata callbacks 2025-02-14 11:07:32 +01:00
7 changed files with 1073 additions and 17 deletions

View File

@@ -484,6 +484,7 @@ dns__db_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
*/
REQUIRE(DNS_DB_VALID(db));
REQUIRE(name != NULL && name != foundname);
REQUIRE(type != dns_rdatatype_rrsig);
REQUIRE(nodep == NULL || *nodep == NULL);
REQUIRE(dns_name_hasbuffer(foundname));
@@ -517,6 +518,7 @@ dns__db_findext(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
*/
REQUIRE(DNS_DB_VALID(db));
REQUIRE(name != NULL && name != foundname);
REQUIRE(type != dns_rdatatype_rrsig);
REQUIRE(nodep == NULL || *nodep == NULL);
REQUIRE(dns_name_hasbuffer(foundname));

View File

@@ -3755,6 +3755,7 @@ found:
sigrdataset, false,
search.version->secure DNS__DB_FLARG_PASS);
if (result == ISC_R_SUCCESS) {
INSIST(0);
result = DNS_R_EMPTYWILD;
}
goto tree_exit;
@@ -4994,8 +4995,8 @@ qpzone_deleterdataset(dns_db_t *db, dns_dbnode_t *dbnode,
nlock = &qpdb->buckets[node->locknum].lock;
NODE_WRLOCK(nlock, &nlocktype);
result = add(qpdb, node, nodename, version, newheader, DNS_DBADD_FORCE,
false, NULL, 0 DNS__DB_FLARG_PASS);
result = add(qpdb, node, nodename, version, newheader, 0, false, NULL,
0 DNS__DB_FLARG_PASS);
NODE_UNLOCK(nlock, &nlocktype);
return result;
}

View File

@@ -449,7 +449,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
* Add in the length of rdata in the new slab that aren't in
* the old slab.
*/
do {
for (size_t i = 0; i < ncount; i++) {
dns_rdata_init(&nrdata);
rdata_from_slab(&ncurrent, rdclass, type, &nrdata);
if (!rdata_in_slab(oslab, reservelen, rdclass, type, &nrdata)) {
@@ -464,12 +464,9 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
nncount++;
added_something = true;
}
ncount--;
} while (ncount > 0);
ncount = nncount;
}
if (((flags & DNS_RDATASLAB_EXACT) != 0) && (tcount != ncount + ocount))
{
if (((flags & DNS_RDATASLAB_EXACT) != 0) && (nncount != ncount)) {
return DNS_R_NOTEXACT;
}
@@ -514,7 +511,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
ncurrent = nslab + reservelen + 2;
if (ncount > 0) {
if (nncount > 0) {
do {
dns_rdata_reset(&nrdata);
rdata_from_slab(&ncurrent, rdclass, type, &nrdata);
@@ -522,11 +519,11 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
&nrdata));
}
while (oadded < ocount || nadded < ncount) {
while (oadded < ocount || nadded < nncount) {
bool fromold;
if (oadded == ocount) {
fromold = false;
} else if (nadded == ncount) {
} else if (nadded == nncount) {
fromold = true;
} else {
fromold = (dns_rdata_compare(&ordata, &nrdata) < 0);
@@ -560,7 +557,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
memmove(tcurrent, data, length);
tcurrent += length;
nadded++;
if (nadded < ncount) {
if (nadded < nncount) {
do {
dns_rdata_reset(&nrdata);
rdata_from_slab(&ncurrent, rdclass,

View File

@@ -24,6 +24,7 @@ check_PROGRAMS = \
dbdiff_test \
dbiterator_test \
dbversion_test \
dbzone_test \
diff_test \
dispatch_test \
dns64_test \

View File

@@ -30,10 +30,6 @@
#include <tests/dns.h>
#define BUFLEN 255
#define BIGBUFLEN (64 * 1024)
#define TEST_ORIGIN "test"
/*
* Individual unit tests
*/

1059
tests/dns/dbzone_test.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -388,8 +388,8 @@ dns_test_rdatafromstring(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
/*
* Set up callbacks so warnings and errors are not printed.
*/
dns_rdatacallbacks_init(&callbacks);
if (!warnings) {
dns_rdatacallbacks_init(&callbacks);
callbacks.warn = callbacks.error = nullmsg;
}