Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 101675
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: johnpc [...] xs4all.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: MX record wih 0 preference fails to parse
Date: Thu, 22 Jan 2015 16:12:35 +0100
To: bug-Net-DNS [...] rt.cpan.org
From: Jan-Pieter Cornet <johnpc [...] xs4all.net>
Hi Net-DNS maintainers, easy to reproduce bug: $ perl -MNet::DNS -le 'print Net::DNS::RR->new(". MX 0 foo")->exchange' Can't call method "name" on an undefined value at /Users/johnpc/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.1/darwin-2level/Net/DNS/RR/MX.pm line 79. Calling with non-zero pref works as expected: $ perl -MNet::DNS -le 'print Net::DNS::RR->new(". MX 1 foo")->exchange' foo This is for: $ perl -MNet::DNS -le 'print $Net::DNS::VERSION' 0.82 The root cause is found in lib/Net/DNS/RR/MX.pm sub parse_rdata, which has: ... $self->preference( shift || return ); Since the preference "0" evaluates as false, this returns before setting the preference and the exchange. The same "shift || return" construct is found in Net::DNS::RR::SOA, where it is less likely to encounter a 0, but still. Also, that construct had me check if I had a large enough bottle of EyeBleach nearby. A side effect is that calling Net::DNS::RR->new(...)->exchange can crash because the exchange is unset. Attached is a proposed patch that fixes it (and adds tests for this). I notice that calling ->name() on elements is much more common, and might cause other crashes on uninitialised records, so a more general solution might be better in this case. -- Jan-Pieter Cornet <johnpc@xs4all.net> Systeembeheer XS4ALL Internet bv www.xs4all.nl

Message body is not shown because sender requested not to inline it.

Download signature.asc
application/pgp-signature 971b

Message body not shown because it is not plain text.

From: rwfranks [...] acm.org
On Thu Jan 22 10:13:00 2015, johnpc@xs4all.net wrote: Show quoted text
> ... > $self->preference( shift || return ); > > Since the preference "0" evaluates as false, this returns before > setting the preference and the exchange.
Clearly wrong Show quoted text
> The same "shift || return" construct is found in Net::DNS::RR::SOA,
Same Show quoted text
> A side effect is that calling Net::DNS::RR->new(...)->exchange can > crash because the exchange is unset.
Show quoted text
> I notice that calling ->name() on elements is much more common, and > might cause other crashes on uninitialised records, so a more general > solution might be better in this case.
The offending bit of code lives in an M4 macro, so this will get applied more generally sometime soon. Thanks
Thanks Jan Pieter, patch committed to trunk and will be in the 0.83 release.