Subject: | Net::DNS::RR::LOC erroneously strips non default values from string representation |
Date: | Fri, 21 Aug 2020 12:05:09 +0100 |
To: | bug-Net-DNS [...] rt.cpan.org |
From: | Phil Gunhouse <rt.cpan.org [...] cochon.co.uk> |
Hi,
The function _format_rdata in LOC.pm invoked by string/plain etc.,
intended to strip out the default RFC-1876 precision values can
erroneously strip valid non default values that happen to match
defaults for other fields.
In the examples below 1m is not the default for either HORIZ PRE or
VERT PRE, but is removed, leaving them to be substituted as per
RFC-1876 incorrectly. My usage case, a pipe backend for PowerDNS where
pdns consumes the textual representation of the record and correctly
substitutes the unwanted default values because the explicit values
have been incorrectly removed.
Net-DNS-1.26 / Perl v5.28.1 / Debian 10.4 amd64
use Net::DNS::Nameserver;
$loc_rr = new Net::DNS::RR(
"good 3600 IN LOC 54 3 2 N 12 3 4 W 123 500 10 2"
);
print $loc_rr->string . "\n";
$loc_rr = new Net::DNS::RR(
"vp-bad 3600 IN LOC 54 3 2 N 12 3 4 W 123 500 10 1"
);
print $loc_rr->string . "\n";
$loc_rr = new Net::DNS::RR(
"hp-bad 3600 IN LOC 54 3 2 N 12 3 4 W 123 500 1 10"
);
print $loc_rr->string . "\n";
good. 3600 IN LOC 54 3 2 N 12 3 4 W 123m 500m 10m 2m
vp-bad. 3600 IN LOC 54 3 2 N 12 3 4 W 123m 500m 10m
hp-bad. 3600 IN LOC 54 3 2 N 12 3 4 W 123m 500m
The following patch should resolve the issue, giving positional context
to the 3 specific default values.
--- LOC.pm.orig
+++ LOC.pm
@@ -46,5 +46,5 @@
for ($precision) {
- s/\s+10m$//;
- s/\s+10000m$//;
- s/\s*1m$//;
+ s/^(\S+\s+\S+)\s+10m$/$1/;
+ s/^(\S+)\s+10000m$/$1/;
+ s/^\s*1m$//;
}
Best Regards,
--
Phil Gunhouse