Skip Menu |

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

Report information
The Basics
Id: 25898
Status: resolved
Priority: 0/
Queue: Net-CIDR-Lite

People
Owner: Nobody in particular
Requestors: athomason [...] sixapart.com
Cc:
AdminCc:

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



Subject: undef dereference in Net::CIDR::Lite
Date: Wed, 28 Mar 2007 14:45:57 -0700
To: bug-Net-CIDR-Lite [...] rt.cpan.org
From: Adam Thomason <athomason [...] sixapart.com>
Hi Doug, The attached/inlined patch addresses an issue in Net-CIDR-Lite-0.20. If an object is created and no ->add* methods are called, ->find dies at line 254 since $cidr->{PACK} has never been defined. The patch thus adds a check for that condition and provides a test for the failing case. Cheers, Adam ----------------- diff -ur Net-CIDR-Lite-0.20/Changes Net-CIDR-Lite-0.21/Changes --- Net-CIDR-Lite-0.20/Changes 2006-02-13 16:43:54.000000000 -0800 +++ Net-CIDR-Lite-0.21/Changes 2007-03-28 14:34:51.000000000 -0700 @@ -1,5 +1,7 @@ Revision history for Perl extension Net::CIDR::Lite. +0.21 Wed Mar 28 14:34:18 2007 + - Fix undef dereference with empty object. 0.20 Sun Feb 12 01:00:00 2006 - Fix error message on mask values. 0.19 Sat Jan 30 01:00:00 2006 diff -ur Net-CIDR-Lite-0.20/Lite.pm Net-CIDR-Lite-0.21/Lite.pm --- Net-CIDR-Lite-0.20/Lite.pm 2006-02-13 16:52:36.000000000 -0800 +++ Net-CIDR-Lite-0.21/Lite.pm 2007-03-28 14:34:55.000000000 -0700 @@ -4,7 +4,7 @@ use vars qw($VERSION); use Carp qw(confess); -$VERSION = '0.20'; +$VERSION = '0.21'; my %masks; my @fields = qw(PACK UNPACK NBITS MASKS); @@ -251,6 +251,7 @@ my $self = shift; $self->prep_find unless $self->{FIND}; return $self->bin_find(@_) unless @{$self->{FIND}} < $self->{PCT}; + return 0 unless $self->{PACK}; my $this_ip = $self->{PACK}->(shift); my $ranges = $self->{RANGES}; my $last = -1; diff -ur Net-CIDR-Lite-0.20/META.yml Net-CIDR-Lite-0.21/META.yml --- Net-CIDR-Lite-0.20/META.yml 2006-02-13 16:53:09.000000000 -0800 +++ Net-CIDR-Lite-0.21/META.yml 2007-03-28 14:35:06.000000000 -0700 @@ -1,10 +1,10 @@ -# http://module-build.sourceforge.net/META-spec.html -#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# -name: Net-CIDR-Lite -version: 0.20 -version_from: Lite.pm -installdirs: site -requires: - -distribution_type: module -generated_by: ExtUtils::MakeMaker version 6.17 +# http://module-build.sourceforge.net/META-spec.html +#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# +name: Net-CIDR-Lite +version: 0.21 +version_from: Lite.pm +installdirs: site +requires: + +distribution_type: module +generated_by: ExtUtils::MakeMaker version 6.17 diff -ur Net-CIDR-Lite-0.20/t/base.t Net-CIDR-Lite-0.21/t/base.t --- Net-CIDR-Lite-0.20/t/base.t 2006-02-13 16:51:29.000000000 -0800 +++ Net-CIDR-Lite-0.21/t/base.t 2007-03-28 14:28:19.000000000 -0700 @@ -8,7 +8,7 @@ use Test; use strict; $|++; -BEGIN { plan tests => 34 }; +BEGIN { plan tests => 35 }; use Net::CIDR::Lite; ok(1); # If we made it this far, we are ok. @@ -17,6 +17,9 @@ # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. +my $empty = Net::CIDR::Lite->new; +ok(!$empty->find('127.0.0.1')); + my $cidr = Net::CIDR::Lite->new; $cidr->add("209.152.214.112/30");
diff -ur Net-CIDR-Lite-0.20/Changes Net-CIDR-Lite-0.21/Changes --- Net-CIDR-Lite-0.20/Changes 2006-02-13 16:43:54.000000000 -0800 +++ Net-CIDR-Lite-0.21/Changes 2007-03-28 14:34:51.000000000 -0700 @@ -1,5 +1,7 @@ Revision history for Perl extension Net::CIDR::Lite. +0.21 Wed Mar 28 14:34:18 2007 + - Fix undef dereference with empty object. 0.20 Sun Feb 12 01:00:00 2006 - Fix error message on mask values. 0.19 Sat Jan 30 01:00:00 2006 diff -ur Net-CIDR-Lite-0.20/Lite.pm Net-CIDR-Lite-0.21/Lite.pm --- Net-CIDR-Lite-0.20/Lite.pm 2006-02-13 16:52:36.000000000 -0800 +++ Net-CIDR-Lite-0.21/Lite.pm 2007-03-28 14:34:55.000000000 -0700 @@ -4,7 +4,7 @@ use vars qw($VERSION); use Carp qw(confess); -$VERSION = '0.20'; +$VERSION = '0.21'; my %masks; my @fields = qw(PACK UNPACK NBITS MASKS); @@ -251,6 +251,7 @@ my $self = shift; $self->prep_find unless $self->{FIND}; return $self->bin_find(@_) unless @{$self->{FIND}} < $self->{PCT}; + return 0 unless $self->{PACK}; my $this_ip = $self->{PACK}->(shift); my $ranges = $self->{RANGES}; my $last = -1; diff -ur Net-CIDR-Lite-0.20/META.yml Net-CIDR-Lite-0.21/META.yml --- Net-CIDR-Lite-0.20/META.yml 2006-02-13 16:53:09.000000000 -0800 +++ Net-CIDR-Lite-0.21/META.yml 2007-03-28 14:35:06.000000000 -0700 @@ -1,10 +1,10 @@ -# http://module-build.sourceforge.net/META-spec.html -#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# -name: Net-CIDR-Lite -version: 0.20 -version_from: Lite.pm -installdirs: site -requires: - -distribution_type: module -generated_by: ExtUtils::MakeMaker version 6.17 +# http://module-build.sourceforge.net/META-spec.html +#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# +name: Net-CIDR-Lite +version: 0.21 +version_from: Lite.pm +installdirs: site +requires: + +distribution_type: module +generated_by: ExtUtils::MakeMaker version 6.17 diff -ur Net-CIDR-Lite-0.20/t/base.t Net-CIDR-Lite-0.21/t/base.t --- Net-CIDR-Lite-0.20/t/base.t 2006-02-13 16:51:29.000000000 -0800 +++ Net-CIDR-Lite-0.21/t/base.t 2007-03-28 14:28:19.000000000 -0700 @@ -8,7 +8,7 @@ use Test; use strict; $|++; -BEGIN { plan tests => 34 }; +BEGIN { plan tests => 35 }; use Net::CIDR::Lite; ok(1); # If we made it this far, we are ok. @@ -17,6 +17,9 @@ # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. +my $empty = Net::CIDR::Lite->new; +ok(!$empty->find('127.0.0.1')); + my $cidr = Net::CIDR::Lite->new; $cidr->add("209.152.214.112/30");
Thanks. Fixed in 0.21.