Skip to content

Commit

Permalink
Merge pull request #15152 from miodvallat/strict_aliasing
Browse files Browse the repository at this point in the history
Make the record representation of ALIAS match CNAME
  • Loading branch information
miodvallat authored Feb 14, 2025
2 parents 4eab2c9 + af0d6ea commit 945d5d2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 7 additions & 1 deletion pdns/dnsrecords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 11 additions & 2 deletions pdns/pdnsutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<<rr.qname<<"\t"<<rr.ttl<<"\tIN\t"<<rr.qtype.toString()<<"\t"<<rr.content<<"\n";
}
Expand Down
4 changes: 3 additions & 1 deletion pdns/zoneparser-tng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment)
}
break;


#if !defined(RECURSOR)
case QType::ALIAS:
#endif
case QType::NS:
case QType::CNAME:
case QType::DNAME:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ external.example.com 120 IN CNAME somewhere.else.net.
external-mail.example.com 120 IN MX 25 server1.test.com.
france.example.com 120 IN NS ns1.otherprovider.net.
france.example.com 120 IN NS ns2.otherprovider.net.
google-alias.example.com 120 IN ALIAS google-public-dns-a.google.com
google-alias.example.com 120 IN ALIAS google-public-dns-a.google.com.
hightype.example.com 120 IN A 192.168.1.5
hightype.example.com 120 IN TYPE65534 \# 5 07ed260001
host-0.example.com 120 IN A 192.168.1.0
Expand Down Expand Up @@ -20338,7 +20338,7 @@ external.example.com 120 IN CNAME somewhere.else.net.
external-mail.example.com 120 IN MX 25 server1.test.com.
france.example.com 120 IN NS ns1.otherprovider.net.
france.example.com 120 IN NS ns2.otherprovider.net.
google-alias.example.com 120 IN ALIAS google-public-dns-a.google.com
google-alias.example.com 120 IN ALIAS google-public-dns-a.google.com.
hightype.example.com 120 IN A 192.168.1.5
hightype.example.com 120 IN TYPE65534 \# 5 07ed260001
host-0.example.com 120 IN A 192.168.1.0
Expand Down

0 comments on commit 945d5d2

Please sign in to comment.