From: Peter van Dijk Date: Tue, 27 Aug 2019 18:39:38 +0000 (+0200) Subject: rfc2136: ignore case when checking PTR/MX/SRV content for duplicates X-Git-Tag: dnsdist-1.4.0~21^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bcdf6537ea957f2928e5cfc929cee9ecb1c7146e;p=thirdparty%2Fpdns.git rfc2136: ignore case when checking PTR/MX/SRV content for duplicates --- diff --git a/pdns/rfc2136handler.cc b/pdns/rfc2136handler.cc index 1797d30808..6e914a2c31 100644 --- a/pdns/rfc2136handler.cc +++ b/pdns/rfc2136handler.cc @@ -216,9 +216,18 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, } else { int updateTTL=0; foundRecord = false; + bool lowerCase = false; + if (rrType.getCode() == QType::PTR || + rrType.getCode() == QType::MX || + rrType.getCode() == QType::SRV) { + lowerCase = true; + } + string content = rr->d_content->getZoneRepresentation(); + if (lowerCase) content = toLower(content); for (auto& i : rrset) { - string content = rr->d_content->getZoneRepresentation(); - if (rrType == i.qtype.getCode() && i.getZoneRepresentation() == content) { + string icontent = i.getZoneRepresentation(); + if (lowerCase) icontent = toLower(icontent); + if (rrType == i.qtype.getCode() && icontent == content) { foundRecord=true; if (i.ttl != rr->d_ttl) { i.ttl = rr->d_ttl; diff --git a/regression-tests/tests/1dyndns-content-casemix/command b/regression-tests/tests/1dyndns-content-casemix/command new file mode 100755 index 0000000000..0dcba160a3 --- /dev/null +++ b/regression-tests/tests/1dyndns-content-casemix/command @@ -0,0 +1,45 @@ +#!/bin/sh +echo == Verify RRset absence +cleandig ptr1.test.dyndns PTR + +echo +echo == Add PTR +cleannsupdate <>HEADER<<- opcode: UPDATE, status: NOERROR, id: [id] +;; flags: qr aa; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0 +;; ZONE SECTION: +;test.dyndns. IN SOA + + +== Verify PTR presence +0 ptr1.test.dyndns. IN PTR 3600 host-2.test.dyndns. +Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0 +Reply to question for qname='ptr1.test.dyndns.', qtype=PTR + +== Add the PTR again +Answer: +;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: [id] +;; flags: qr aa; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0 +;; ZONE SECTION: +;test.dyndns. IN SOA + + +== Verify that we have one PTR +0 ptr1.test.dyndns. IN PTR 3600 host-2.test.dyndns. +Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0 +Reply to question for qname='ptr1.test.dyndns.', qtype=PTR + +== Clean up +Answer: +;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: [id] +;; flags: qr aa; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0 +;; ZONE SECTION: +;test.dyndns. IN SOA + + +== Verify RRset absence +1 test.dyndns. IN SOA 3600 ns1.test.dyndns. ahu.example.dyndns. 2019082711 28800 7200 604800 86400 +Rcode: 3 (Non-Existent domain), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0 +Reply to question for qname='ptr1.test.dyndns.', qtype=PTR diff --git a/regression-tests/tests/1dyndns-content-casemix/skip.nodyndns b/regression-tests/tests/1dyndns-content-casemix/skip.nodyndns new file mode 100644 index 0000000000..81c071b810 --- /dev/null +++ b/regression-tests/tests/1dyndns-content-casemix/skip.nodyndns @@ -0,0 +1 @@ +Skip this test if the backend does not support dyndns/rfc2136