Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: 1fea [...] packet-pushers.com
Cc:
AdminCc:

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



Subject: Can't call method "zclass" on an undefined value at ... Net/DNS/Packet.pm line 474
An issue was reported to the fpdns repository: https://github.com/kirei/fpdns/issues/8 I traced through the code, found what fpdns is doing and replicated it in the small program below. 1 #!/usr/bin/perl 2 use strict; 3 use warnings; 4 use Net::DNS::Packet; 5 6 my $packet = new Net::DNS::Packet; 7 my $q = new Net::DNS::Question('.', 'IN', 'A'); 8 9 $packet->header->opcode('UPDATE'); 10 $packet->push('question', $q); Essentially, it seems when a packet header has opcode set to UPDATE, the push method fails because it expects the question (aka 'zone') section to be non-empty: 468 sub push { 469 my $self = shift; 470 my $list = $self->_section(shift); 471 my @rr = grep ref($_), @_; 472 473 if ( $self->header->opcode eq 'UPDATE' ) { 474 my $zclass = ( $self->zone )[0]->zclass; 475 foreach (@rr) { 476 $_->class($zclass) unless $_->class =~ /ANY|NONE/; 477 } 478 } 479 480 return CORE::push( @$list, @rr ); 481 }
From: rwfranks [...] acm.org
On Thu Jun 25 22:10:21 2015, wessels wrote: Show quoted text
> An issue was reported to the fpdns repository: > > https://github.com/kirei/fpdns/issues/8 > > I traced through the code, found what fpdns is doing and replicated it > in the small program below. > > 1 #!/usr/bin/perl > 2 use strict; > 3 use warnings; > 4 use Net::DNS::Packet; > 5 > 6 my $packet = new Net::DNS::Packet; > 7 my $q = new Net::DNS::Question('.', 'IN', 'A'); > 8 > 9 $packet->header->opcode('UPDATE'); > 10 $packet->push('question', $q); >
The documentation for $packet->push() only describes pushing RRs. Pushing questions is questionable, but happens to work. The "proper" way to create an update packet is: $update = new Net::DNS::Update( $zone ); which fails if the zone is missing or undefined. Even without that, the problem could have been avoided with little effort. Show quoted text
> Essentially, it seems when a packet header has opcode set to UPDATE, > the push method fails > because it expects the question (aka 'zone') section to be non-empty:
The 'zone' section is always non-empty for "proper" update packets. Having said all that, it seems fundamentally unsound to encumber $packet->push() with logic which is only ever applicable to $update->push(). Effectively, the current code constrains the order in which components can be added to an empty packet, which is arbitrary and unreasonable. The two push() methods are clearly different animals, and the code should reflect this. The DIY update packet construction described does not follow the published object model, so can not properly be regarded as a Net::DNS issue. Luckily, my proposed design change also makes your problem disappear entirely.
Resolved in upcoming release