From f6025d9f3409174ae1889caa4b94b4df2dcfa874 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Tue, 13 Apr 2021 06:36:03 +1200 Subject: [PATCH] dlz_bind9: remove redundant logging in b9_record_match() This log message will never be seen. We know because: 1. Always (two places) we are comparing an incoming record against a database record. 2. The incoming record has come from b9_parse(), which makes the same check. 3. If the database record is bad, we will never get here because the first check is b9_record_match() is if (rec1->wType != rec2->wType) { return false; } and rec1->wType is not going to equal the corrupt database record's wType, because point 2. OK, but why? So we can shift this into dnsserver_common.c, because the internal dns server has an inferior record_match() and it could do with sharing this one. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- source4/dns_server/dlz_bind9.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c index 38fc15534be..eba4bebb8f5 100644 --- a/source4/dns_server/dlz_bind9.c +++ b/source4/dns_server/dlz_bind9.c @@ -1753,11 +1753,12 @@ exit: return result; } + /* see if two dns records match */ -static bool b9_record_match(struct dlz_bind9_data *state, - struct dnsp_DnssrvRpcRecord *rec1, struct dnsp_DnssrvRpcRecord *rec2) +static bool b9_record_match(struct dnsp_DnssrvRpcRecord *rec1, + struct dnsp_DnssrvRpcRecord *rec2) { bool status; int i; @@ -1827,8 +1828,6 @@ static bool b9_record_match(struct dlz_bind9_data *state, rec1->data.soa.expire == rec2->data.soa.expire && rec1->data.soa.minimum == rec2->data.soa.minimum; default: - state->log(ISC_LOG_ERROR, "samba_dlz b9_record_match: unhandled record type %u", - rec1->wType); break; } @@ -1944,11 +1943,11 @@ _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo first = num_recs; } - /* there are existing records. We need to see if this will + /* there may be existing records. We need to see if this will * replace a record or add to it */ for (i=first; i < num_recs; i++) { - if (b9_record_match(state, rec, &recs[i])) { + if (b9_record_match(rec, &recs[i])) { break; } } @@ -2066,7 +2065,7 @@ _PUBLIC_ isc_result_t dlz_subrdataset(const char *name, const char *rdatastr, vo } for (i=0; i < num_recs; i++) { - if (b9_record_match(state, rec, &recs[i])) { + if (b9_record_match(rec, &recs[i])) { recs[i] = (struct dnsp_DnssrvRpcRecord) { .wType = DNS_TYPE_TOMBSTONE, };