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 }