Skip Menu |

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

Report information
The Basics
Id: 91435
Status: resolved
Priority: 0/
Queue: Net-Whois-IANA

People
Owner: Nobody in particular
Requestors: eli [...] siliconsprawl.com
Cc:
AdminCc:

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



Subject: Incorrect Range Expansion of Abbreviated CIDRs
LACNIC uses an unusual abbreviated CIDR notation. Net::CIDR doesn't consider this notation valid, but still tries to expand it into a range. The range it comes up with is busted. Here's a script and output showing the problem and one (hackish) way of rewriting the screwy CIDRs into the normal format: ------------------------------------------------ Script: use Net::CIDR; use Net::Whois::IANA; my $iana = Net::Whois::IANA->new; $iana->whois_query(-ip => '191.96.58.222'); print "CIDR: ", $iana->cidr->[0], "\n"; print "Range: ", $iana->inetnum, "\n"; print "Net::CIDR considers invalid\n" unless Net::CIDR::cidrvalidate($iana->cidr); my $cidr = $iana->cidr()->[0]; my $num_dots = $cidr =~ tr/\.//; $cidr =~ s/(?:\d+\.)*\d+/$& . '.0' x (3 - $num_dots)/e; print "Fixed CIDR: $cidr\n"; print "Fixed Range: ", Net::CIDR::cidr2range($cidr), "\n"; print "Net::CIDR considers valid\n" if Net::CIDR::cidrvalidate($cidr); ------------------------------------------------- Output: CIDR: 191.96/16 Range: 191.96-191.96 Net::CIDR considers invalid Fixed CIDR: 191.96.0.0/16 Fixed Range: 191.96.0.0-191.96.255.255 Net::CIDR considers valid
On Sun Dec 15 15:51:14 2013, https://www.google.com/accounts/o8/id?id=AItOawmUqDfWICIMz_fwUIshaTn8ORdDj523HxU wrote: Show quoted text
> LACNIC uses an unusual abbreviated CIDR notation. Net::CIDR doesn't > consider this notation valid, but still tries to expand it into a > range. The range it comes up with is busted. > > Here's a script and output showing the problem and one (hackish) way > of rewriting the screwy CIDRs into the normal format: > > ------------------------------------------------ > Script: > > use Net::CIDR; > use Net::Whois::IANA; > > my $iana = Net::Whois::IANA->new; > $iana->whois_query(-ip => '191.96.58.222'); > > print "CIDR: ", $iana->cidr->[0], "\n"; > print "Range: ", $iana->inetnum, "\n"; > print "Net::CIDR considers invalid\n" unless > Net::CIDR::cidrvalidate($iana->cidr); > > my $cidr = $iana->cidr()->[0]; > my $num_dots = $cidr =~ tr/\.//; > $cidr =~ s/(?:\d+\.)*\d+/$& . '.0' x (3 - $num_dots)/e; > print "Fixed CIDR: $cidr\n"; > print "Fixed Range: ", Net::CIDR::cidr2range($cidr), "\n"; > print "Net::CIDR considers valid\n" if Net::CIDR::cidrvalidate($cidr); > > ------------------------------------------------- > Output: > > CIDR: 191.96/16 > Range: 191.96-191.96 > Net::CIDR considers invalid > Fixed CIDR: 191.96.0.0/16 > Fixed Range: 191.96.0.0-191.96.255.255 > Net::CIDR considers valid
moved to https://github.com/atoomic/Net-Whois-IANA/issues/4