diff -ur Net-IP-1.25/IP.pm Net-IP-1.26/IP.pm
--- Net-IP-1.25/IP.pm 2006-05-22 18:46:40.000000000 +0200
+++ Net-IP-1.26/IP.pm 2009-09-03 18:59:52.994133875 +0200
@@ -40,6 +40,7 @@
package Net::IP;
use strict;
+use Carp qw(croak);
use Math::BigInt;
# Global Variables definition
@@ -47,7 +48,7 @@
%IPv4ranges %IPv6ranges $useBigInt
$IP_NO_OVERLAP $IP_PARTIAL_OVERLAP $IP_A_IN_B_OVERLAP $IP_B_IN_A_OVERLAP $IP_IDENTICAL);
-$VERSION = '1.25';
+$VERSION = '1.26';
require Exporter;
@@ -1770,12 +1771,12 @@
if ($ip_version == 4) {
my @quads = split /\./, $ip;
my $no_quads = ($len / 8);
+ croak("A /$len object does not have a defined reverse name")
+ if $no_quads != int $no_quads;
my @reverse_quads = reverse @quads;
- while (@reverse_quads and $reverse_quads[0] == 0) {
- shift(@reverse_quads);
- }
+ splice @reverse_quads, 0, 4 - $no_quads;
return join '.', @reverse_quads, 'in-addr', 'arpa.';
}
diff -ur Net-IP-1.25/t/ipv4.t Net-IP-1.26/t/ipv4.t
--- Net-IP-1.25/t/ipv4.t 2006-04-26 10:35:42.000000000 +0200
+++ Net-IP-1.26/t/ipv4.t 2009-09-03 18:55:30.410538089 +0200
@@ -12,7 +12,7 @@
};
};
-my $numtests = 26;
+my $numtests = 27;
# Create checker:
my $T = typical ExtUtils::TBone;
@@ -43,6 +43,11 @@
$T->ok_eq ($ip->last_bin(),'11000011011100100101000011111111',$ip->error());
$T->ok_eq ($ip->last_ip(),'195.114.80.255',$ip->error());
+{ # for #42793: reverse_ip Bug
+ my $ip = Net::IP->new('195.114.80.0');
+ $T->ok_eq( $ip->reverse_ip, '0.80.114.195.in-addr.arpa.', $ip->error );
+}
+
$ip->set('202.31.4/24');
$T->ok_eq ($ip->ip(),'202.31.4.0',$ip->error());
Only in Net-IP-1.26: testout