Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: yath [...] yath.de
Cc:
AdminCc:

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



Subject: [PATCH] Don't interpret 0 in CERT format or algorithm as undef
Date: Sun, 9 Dec 2012 00:12:52 +0100
To: bug-Net-DNS [...] rt.cpan.org
From: Sebastian Schmidt <yath [...] yath.de>
Net::DNS::RR::CERT sets "<undef>" as default value for format or algorithm when a false value is passed. As <undef> doesn't resolve to a mnemonic, an error is thrown. Since 0 or "0" is false as well it's impossible to set either of these attributes to 0, yet an algorithm of type 0 is perfectly legal. Although 0 for the format is defined as "Reserved" in RFC4398 2.1 it's not invalid either. This patch addresses this issue by only defaulting to "<undef>" when the argument passed to ->format or ->algorithm is undef and not anything else evaluating to false. A test case has been added as well. --- lib/Net/DNS/RR/CERT.pm | 6 ++++-- t/05-CERT.t | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Net/DNS/RR/CERT.pm b/lib/Net/DNS/RR/CERT.pm index b1ec4d1..e66cab4 100644 --- a/lib/Net/DNS/RR/CERT.pm +++ b/lib/Net/DNS/RR/CERT.pm @@ -95,7 +95,8 @@ sub format { return $self->{format} unless @_; - my $format = shift || '<undef>'; + my $format = shift; + $format = '<undef>' unless defined $format; $format = $formats{$format} || die "Unknown mnemonic: '$format'" if $format =~ /\D/; # look up mnemonic $self->{format} = $format; @@ -113,7 +114,8 @@ sub algorithm { return $self->{algorithm} unless @_; - my $algorithm = shift || '<undef>'; + my $algorithm = shift; + $algorithm = '<undef>' unless defined $algorithm; $algorithm = $algorithms{$algorithm} || die "Unknown mnemonic: '$algorithm'" if $algorithm =~ /\D/; # look up mnemonic $self->{algorithm} = $algorithm; diff --git a/t/05-CERT.t b/t/05-CERT.t index c0ba2ca..57cda1f 100644 --- a/t/05-CERT.t +++ b/t/05-CERT.t @@ -1,7 +1,7 @@ # $Id: 05-CERT.t 1068 2012-12-06 10:38:51Z willem $ -*-perl-*- use strict; -use Test::More tests => 11; +use Test::More tests => 14; use Net::DNS; @@ -63,6 +63,11 @@ my $wire = '00010002033132333435363738396162636465666768696a6b6c6d6e6f7071727374 is( length($rxtext), length($null), 'string RDATA can be empty' ); } +{ + is(Net::DNS::RR->new("foo IN CERT 0 2 3 foo")->format, 0, 'format may be zero'); + is(Net::DNS::RR->new("foo IN CERT 1 0 3 foo")->tag, 0, 'tag may be zero'); + is(Net::DNS::RR->new("foo IN CERT 1 2 0 foo")->algorithm, 0, 'algorithm may be zero'); +} exit; -- 1.7.10.4
Download signature.asc
application/pgp-signature 190b

Message body not shown because it is not plain text.

From: rwfranks [...] acm.org
Thanks for the patch, which will appear in 0.71