Skip Menu |
 

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

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

People
Owner: cpan [...] bat.ru
Requestors: MSCHILLI [...] cpan.org
Cc:
AdminCc:

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

Attachments
0001-Fix-by-Tom-Rutledge-to-let-Net-IP-deal-with-zero-IPs.patch



Subject: Fix to let Net::IP deal with zero IPs or networks based off of it
Download (untitled) / with headers
text/plain 121b
Please find attached a fix by Tom Rutledge to let Net::IP deal with zero IPs or networks based off of it, e.g. 0.0.0.0/0.
Subject: 0001-Fix-by-Tom-Rutledge-to-let-Net-IP-deal-with-zero-IPs.patch
From 0f5c1560eb11f0913895c3ac24d1f92d6133f96c Mon Sep 17 00:00:00 2001 From: mschilli <github@perlmeister.com> Date: Tue, 17 Aug 2010 14:11:20 -0700 Subject: [PATCH] Fix by Tom Rutledge to let Net::IP deal with zero IPs or networks based off of it, e.g. 0.0.0.0/0. --- IP.pm | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/IP.pm b/IP.pm index eec2023..2d17453 100644 --- a/IP.pm +++ b/IP.pm @@ -410,7 +410,9 @@ sub intip { my $int = ip_bintoint($self->binip()); - if (!$int) { + # this then fails for 0.0.0.0 , which is wrong. + # + if (not defined $int) { $self->{error} = $ERROR; $self->{errno} = $ERRNO; return; @@ -619,9 +621,11 @@ sub last_int { return ($self->{last_int}) if defined($self->{last_int}); - my $last_bin = $self->last_bin() or return; + my $last_bin = $self->last_bin(); + return unless defined $last_bin; - my $last_int = ip_bintoint($last_bin, $self->version()) or return; + my $last_int = ip_bintoint($last_bin, $self->version()); + return unless defined $last_int; $self->{last_int} = $last_int; @@ -1235,11 +1239,13 @@ sub ip_prefix_to_range { # Turn into a binary # Get last address # Turn into an IP - my $binip = ip_iptobin($ip, $ip_version) or return; + my $binip = ip_iptobin($ip, $ip_version) ; + return unless defined $binip; return unless (ip_check_prefix($binip, $len, $ip_version)); - my $lastip = ip_last_address_bin($binip, $len, $ip_version) or return; + my $lastip = ip_last_address_bin($binip, $len, $ip_version); + return unless defined $lastip; return unless ($lastip = ip_bintoip($lastip, $ip_version)); return ($ip, $lastip); -- 1.7.0.4
The patch will be committed into 1.27 release.


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.