Skip Menu |

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

Report information
The Basics
Id: 59566
Status: rejected
Priority: 0/
Queue: NetAddr-IP

People
Owner: Nobody in particular
Requestors: NEPOS [...] cpan.org
Cc:
AdminCc:

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



Subject: contains() and within() should check the address family
Hello, Just played around a bit and noticed that the following check works for every IPv4 address: use NetAddr::IP; my $net_a = NetAddr::IP->new('::', 0) or die; my $net_b = NetAddr::IP->new('1.2.3.4') or die; print "V6 contains V4\n" if ($net_a->contains($net_b)); In my opinion it should be checked if both NetAddr::IP objects have the same address family or version. -- Matthias
On Tue Jul 20 09:33:47 2010, NEPOS wrote: Show quoted text
> Hello, > > Just played around a bit and noticed that the following check works for > every IPv4 address: > > use NetAddr::IP; > my $net_a = NetAddr::IP->new('::', 0) or die; > my $net_b = NetAddr::IP->new('1.2.3.4') or die; > > print "V6 contains V4\n" if ($net_a->contains($net_b)); > > In my opinion it should be checked if both NetAddr::IP objects have the > same address family or version. > > -- Matthias
NetAddr::IP documentation says: The internal representation of all IP objects is in 128 bit IPv6 notation. IPv4 and IPv6 objects may be freely mixed. The "notation" of IPv4 or IPv6 does not change where in the address space the particular IP address resides. In your example, 1.2.3.4 is included in ::/0 which includes all IPv4 address space.