From af0d6ea278c500c01cdf7f4cbe459d20d893aa09 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Thu, 13 Feb 2025 17:15:34 +0100 Subject: [PATCH] Make the record representation of ALIAS match CNAME... ...but for the name compression. This will correctly remove non-root trailing dots from ALIAS records. Fixes #5500, #7827 --- pdns/dnsrecords.cc | 8 +++++++- pdns/pdnsutil.cc | 13 +++++++++++-- pdns/zoneparser-tng.cc | 4 +++- .../lmdb-schema-upgrade/expected_result | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index e096be81ef7f..85ce9e471ef0 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -36,7 +36,10 @@ void DNSResourceRecord::setContent(const string &cont) { case QType::MX: if (content.size() >= 2 && *(content.rbegin()+1) == ' ') return; - /* Falls through. */ + [[fallthrough]]; +#if !defined(RECURSOR) + case QType::ALIAS: +#endif case QType::CNAME: case QType::DNAME: case QType::NS: @@ -64,6 +67,9 @@ string DNSResourceRecord::getZoneRepresentation(bool noDot) const { if (*(last.rbegin()) != '.' && !noDot) ret << "."; break; +#if !defined(RECURSOR) + case QType::ALIAS: +#endif case QType::CNAME: case QType::DNAME: case QType::NS: diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 3a35755fd051..4ab130292ccf 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1113,8 +1113,17 @@ static int listZone(const DNSName &zone) { while(di.backend->get(rr)) { if(rr.qtype.getCode() != 0) { - if ( (rr.qtype.getCode() == QType::NS || rr.qtype.getCode() == QType::SRV || rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::CNAME) && !rr.content.empty() && rr.content[rr.content.size()-1] != '.') - rr.content.append(1, '.'); + switch (rr.qtype.getCode()) { + case QType::ALIAS: + case QType::CNAME: + case QType::MX: + case QType::NS: + case QType::SRV: + if (!rr.content.empty() && rr.content[rr.content.size()-1] != '.') { + rr.content.append(1, '.'); + } + break; + } cout<