Skip Menu |
 

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

Report information
The Basics
Id: 7528
Status: resolved
Priority: 0/
Queue: Net-IP

People
Owner: manuel.valente [...] gmail.com
Requestors: serge.droz [...] switch.ch
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.20
Fixed in: 1.23



Subject: Problem with /31 subnets in ip_range_to_prefix
Download (untitled) / with headers
text/plain 255b
ip_range_to_prefix returns the wrong result for subnets containing only two hosts, i.e. /31 subnets. The reason is the statement if($1) { which should really real if($1 ne "") { to test the number of zeros. The included patch fixes this problem.
Download Net-IP-prefix.patch
text/x-diff 337b
--- Net-IP-1.20.orig/IP.pm Wed Apr 9 13:42:25 2003 +++ Net-IP-1.20/IP.pm Tue Aug 31 14:05:59 2004 @@ -1536,7 +1536,7 @@ $binip =~ m/(0+)$/; # nbits = nb of 0 bits - if ($1) { + if ($1 ne "") { $nbits = length ($1); } else {
From: adrian [...] xemacs.org
Download (untitled) / with headers
text/plain 417b
[guest - Tue Aug 31 08:34:30 2004]: Show quoted text
> ip_range_to_prefix returns the wrong result for subnets containing > only two hosts, i.e. /31 subnets. The reason is the statement > if($1) { > > > which should really real > if($1 ne "") { > > to test the number of zeros. > The included patch fixes this problem.
Please consider this patch against Net-IP 1.20, which I find slightly better. Best regards, Adrian
Download IP.pm.patch
text/x-diff 787b
cd c:\Perl\site\lib\Net\ diff -u IP.pm.orig IP.pm Compilation started at Thu Nov 04 22:38:54 2004 +0100 (W. Europe Standard Time) --- IP.pm.orig 2003-04-09 14:42:25.000000000 +0200 +++ IP.pm 2004-11-04 22:38:46.000000000 +0100 @@ -1533,10 +1533,8 @@ while (ip_bincomp ($binip,'le',$endbinip) == 1) { # Find all 0s at the end - $binip =~ m/(0+)$/; - # nbits = nb of 0 bits - - if ($1) { + if ($binip =~ m/(0+)$/) { + # nbits = nb of 0 bits $nbits = length ($1); } else { Compilation exited abnormally with code 1 at Thu Nov 04 22:38:54
Download (untitled) / with headers
text/plain 495b
[guest - Thu Nov 4 16:47:20 2004]: Show quoted text
> [guest - Tue Aug 31 08:34:30 2004]: >
> > ip_range_to_prefix returns the wrong result for subnets containing > > only two hosts, i.e. /31 subnets. The reason is the statement > > if($1) { > > > > > > which should really real > > if($1 ne "") { > > > > to test the number of zeros. > > The included patch fixes this problem.
> > Please consider this patch against Net-IP 1.20, which I find slightly > better. > > Best regards, > > Adrian > >
Download ChangeLog
application/octet-stream 236b

Message body not shown because it is not plain text.

From: ville.skytta [...] iki.fi
This is still broken in 1.22. Updated patch containing a test case attached.
http://rt.cpan.org/NoAuth/Bug.html?id=7528 diff -ru Net-IP-1.22.orig/IP.pm Net-IP-1.22/IP.pm --- Net-IP-1.22.orig/IP.pm 2005-05-27 12:01:23.000000000 +0300 +++ Net-IP-1.22/IP.pm 2005-05-28 11:54:07.000000000 +0300 @@ -1529,10 +1529,8 @@ while (ip_bincomp ($binip,'le',$endbinip) == 1) { # Find all 0s at the end - $binip =~ m/(0+)$/; - # nbits = nb of 0 bits - - if ($1) { + if ($binip =~ m/(0+)$/) { + # nbits = nb of 0 bits $nbits = length ($1); } else { diff -ru Net-IP-1.22.orig/t/ipv4.t Net-IP-1.22/t/ipv4.t --- Net-IP-1.22.orig/t/ipv4.t 2003-02-14 11:38:03.000000000 +0200 +++ Net-IP-1.22/t/ipv4.t 2005-05-28 11:56:48.000000000 +0300 @@ -12,7 +12,7 @@ }; }; -my $numtests = 21; +my $numtests = 23; # Create checker: my $T = typical ExtUtils::TBone; @@ -60,9 +60,13 @@ $T->ok_eqnum ($ip->bincomp('gt',$ip2),1,$ip->error()); $ip = new Net::IP('133.44.255.255-133.45.0.42'); - $T->ok_eq (($ip->find_prefixes())[3],'133.45.0.40/31',$ip->error()); +$ip = new Net::IP('192.168.2.254-192.168.2.255'); +my @prefixes = $ip->find_prefixes(); +$T->ok_eqnum (scalar(@prefixes), 1); +$T->ok_eq ($prefixes[0],'192.168.2.254/31',$ip->error()); + $ip->set('201.33.128.0/22'); $ip2->set('201.33.129.0/24');
From: mvalente [...] idealx.com
Download (untitled) / with headers
text/plain 226b
[SCOP - Sat May 28 05:12:50 2005]: Show quoted text
> This is still broken in 1.22. > > Updated patch containing a test case attached.
The patch is now included in version 1.23, uploaded to CPAN, and all tests pass. Thanks for the help.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.