Skip Menu |

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

Report information
The Basics
Id: 20219
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: Net-Patricia

People
Owner: PHILIPP [...] cpan.org
Requestors: LIOL [...] cpan.org
Cc: philipp [...] redfish-solutions.com
AdminCc:

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



Subject: 0.0.0.0/0 wrong interpolation on amd64
use Net::Patricia; my $pt = new Net::Patricia(); $pt->add_string("0.0.0.0/0",'all'); print "1 ", $pt->match_string('195.64.1.1'), "\n"; $pt->add_string("128.0.0.0/1",'all'); $pt->add_string("0.0.0.0/1",'all'); print "2 ", $pt->match_string('195.64.1.1'), "\n"; 1 2 all -- Best regards, Lobanov Igor liol@cpan.org Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=freebsd, osvers=6.1-stable, archname=amd64-freebsd config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=y, bincompat5005=undef Compiler: cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include', optimize='-O2 -fno-strict-aliasing -pipe ', cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include' ccversion='', gccversion='3.4.4 [FreeBSD] 20050518', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lm -lcrypt -lutil perllibs=-lm -lcrypt -lutil libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib'
From: liol
On Sat Jul 01 05:14:36 2006, LIOL wrote: Show quoted text
> 0.0.0.0/0 wrong interpolation on amd64
"interpretation" of course. Sorry -- Best regards, Lobanov Igor liol@cpan.org
From: dformosa [...] iseek.com.au
On Fri Jul 07 04:54:17 2006, LIOL wrote: Show quoted text
> On Sat Jul 01 05:14:36 2006, LIOL wrote: >
> > 0.0.0.0/0 wrong interpolation on amd64
> "interpretation" of course. Sorry
The patch attached fixes this problem on all platforms.
Index: Patricia.xs =================================================================== --- Patricia.xs (revision 22) +++ Patricia.xs (revision 25) @@ -140,7 +140,7 @@ #define Fill_Prefix(p,f,a,b,mb) \ do { \ - if (b <= 0 || b > mb) \ + if (b < 0 || b > mb) \ croak("invalid key"); \ memcpy(&p.add.sin, a, (mb+7)/8); \ p.family = f; \ Index: Patricia.pm =================================================================== --- Patricia.pm (revision 22) +++ Patricia.pm (revision 25) @@ -86,37 +86,37 @@ sub Net::Patricia::AF_INET::add { my ($self, $ip, $bits, $data) = @_; - $data ||= $bits ? "$ip/$bits" : $ip; + $data ||= defined $bits ? "$ip/$bits" : $ip; my $packed = inet_aton($ip) || croak("invalid key"); - _add($self,AF_INET,$packed,$bits || 32, $data); + _add($self,AF_INET,$packed,(defined $bits ? $bits : 32), $data); } sub Net::Patricia::AF_INET::match_integer { my ($self, $num, $bits) = @_; - _match($self,AF_INET,pack("N",$num),$bits || 32); + _match($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32)); } sub Net::Patricia::AF_INET::exact_integer { my ($self, $num, $bits) = @_; - _exact($self,AF_INET,pack("N",$num),$bits || 32); + _exact($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32)); } sub Net::Patricia::AF_INET::match { my ($self, $ip, $bits) = @_; my $packed = inet_aton($ip) || croak("invalid key"); - _match($self,AF_INET,$packed,$bits || 32); + _match($self,AF_INET,$packed,(defined $bits ? $bits : 32)); } sub Net::Patricia::AF_INET::exact { my ($self, $ip, $bits) = @_; my $packed = inet_aton($ip) || croak("invalid key"); - _exact($self,AF_INET,$packed,$bits || 32); + _exact($self,AF_INET,$packed,(defined $bits ? $bits : 32)); } sub Net::Patricia::AF_INET::remove { my ($self, $ip, $bits) = @_; my $packed = inet_aton($ip) || return undef; - _remove($self,AF_INET,$packed,$bits || 32); + _remove($self,AF_INET,$packed,(defined $bits ? $bits : 32)); } Index: test.pl =================================================================== --- test.pl (revision 22) +++ test.pl (revision 25) @@ -6,7 +6,7 @@ # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) -BEGIN { $| = 1; $debug = 1; print "1..18\n"; } +BEGIN { $| = 1; $debug = 1; print "1..19\n"; } END {print "not ok 1\n" unless $loaded;} use Net::Patricia; $loaded = 1; @@ -128,6 +128,10 @@ print "not ok 18\n" } +$t->add_string('0/0'); + +print $t->match_string("10.0.0.1")?"ok 19\n":"not ok 19\n"; + undef $t; exit;
Subject: 0.0.0.0/0 wrong interpretation on amd64
I've merged your patch with the proposed fix to 14244: https://rt.cpan.org/Ticket/Display.html?id=14244 Please add yourselves to the Cc list for that bug.
Duplicated to 14244.