Skip Menu |
 

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

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

People
Owner: cpan [...] bat.ru
Requestors: andreas.papst [...] univie.ac.at
Cc:
AdminCc:

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



MIME-Version: 1.0
X-Spam-Status: No, hits=-1.0 required=8.0 tests=DKIM_SIGNED,RCVD_IN_DNSWL_LOW
Content-Disposition: inline
content-type: text/plain; charset="utf-8"
Message-ID: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at>
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 39BA623C103 for <bug-Net-IP [...] rt.cpan.org>; Mon, 26 Jan 2009 04:26:51 -0500 (EST)
Received: (qmail 14528 invoked by uid 103); 26 Jan 2009 09:26:51 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 26 Jan 2009 09:26:51 -0000
Received: from grace.univie.ac.at (HELO grace.univie.ac.at) (131.130.3.115) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Jan 2009 01:26:47 -0800
Received: from justin.univie.ac.at ([131.130.3.111] helo=justin.univie.ac.at) by grace.univie.ac.at with esmtp (Exim 4.69) (envelope-from <ap [...] snoopy.cc.univie.ac.at>) id 1LRNjK-000445-V5 for bug-Net-IP [...] rt.cpan.org; Mon, 26 Jan 2009 10:26:06 +0100
Received: from snoopy.cc.univie.ac.at ([131.130.249.133] helo=snoopy.cc.univie.ac.at) by justin.univie.ac.at with esmtp (Exim 4.69) (envelope-from <ap [...] snoopy.cc.univie.ac.at>) id 1LRNjK-0006vf-U7 for bug-Net-IP [...] rt.cpan.org; Mon, 26 Jan 2009 10:26:06 +0100
Received: (from ap [...] localhost) by snoopy.cc.univie.ac.at (AIX5.3/8.13.4/8.11.6p2) id n0Q9Q6ps1327188 for bug-Net-IP [...] rt.cpan.org; Mon, 26 Jan 2009 10:26:06 +0100
Delivered-To: cpan-bug+Net-IP [...] diesel.bestpractical.com
Subject: reverse_ip Bug
User-Agent: Mutt/1.4.2.1i
Return-Path: <ap [...] snoopy.cc.univie.ac.at>
X-Original-To: bug-Net-IP [...] rt.cpan.org
X-Spam-Check-BY: 16.mx.develooper.com
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=univie.ac.at; s=rev1; h=From:Date:To:Subject:Message-ID: Mime-Version:Content-Type; bh=8gxthYdRF0GCuvVVCr33GUggcL6L4oWNCy t4LgKszkc=; b=AMGpB1K7oLm1IF9fmR8Sd/JbTbbNJMp4/D6K02d/curgUsbskZ hUK8m19jB4lhwHoPu5zjOB53SYMQsQRKcSHPjfrZqSvjACkgoSImDj5y+tJ8Ks7V TnO8mf+anZKR4sug/Xrn810CS7XZ3uWzauZGcA54kMzC/mcFiSXF4Mk2Q=
Date: Mon, 26 Jan 2009 10:26:06 +0100
X-Spam-Level: *
To: bug-Net-IP [...] rt.cpan.org
From: Andreas Papst <andreas.papst [...] univie.ac.at>
X-RT-Original-Encoding: us-ascii
Content-Length: 288
Download (untitled) / with headers
text/plain 288b
Hi, Net::IP has a function reverse_ip that should return the reverse IP in in-addr.arpa notation. In case of 1.2.3.0 it does not and returns 3.2.1.in-addr.arpa instead of 0.3.2.1.in-addr.arpa. If you edit ip_reverse to not omit leading 0s, other functions fail. Kind Regards Andreas
MIME-Version: 1.0
In-Reply-To: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
References: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at>
Content-Type: multipart/mixed; boundary="----------=_1251997356-27252-88"
Message-ID: <rt-3.6.HEAD-27252-1251997356-307.42793-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
RT-Send-CC: manuel.valente [...] gmail.com
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 101
Download (untitled) / with headers
text/plain 101b
I've just discovered the same problem. Please find my suggestion for a patch attached. Regards, fany
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1251997356-27252-87"
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: text/x-patch; name="Net-IP.reverse_ip.patch"
Content-Disposition: inline; filename="Net-IP.reverse_ip.patch"
Content-Transfer-Encoding: binary
Content-Length: 1741
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
MIME-Version: 1.0
In-Reply-To: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Charset: utf8
References: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at>
Content-Type: text/plain
Message-ID: <rt-3.6.HEAD-27252-1252052512-1026.42793-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 67
Also see bug #25169 (and maybe merge them, if the system lets you.)
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-27252-1252052512-1026.42793-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
References: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at> <rt-3.6.HEAD-27252-1252052512-1026.42793-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1305149208-18809-311"
Message-ID: <rt-3.8.HEAD-18809-1305149208-1944.42793-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 226
Download (untitled) / with headers
text/plain 226b
On Fri Sep 04 04:21:52 2009, FANY wrote: Show quoted text
> Also see bug #25169 (and maybe merge them, if the system lets you.)
This bug is being fixed in Debian using the following patch. So now whoever owns this module can take their pick.
Subject: ip_reverse.patch
MIME-Version: 1.0
Content-Type: text/x-patch; name="ip_reverse.patch"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="ip_reverse.patch"
Content-Transfer-Encoding: binary
Content-Length: 1659
Download ip_reverse.patch
text/x-diff 1.6k
Author: Nicholas Bamber <nicholas@periapt.co.uk> Bug: http://rt.cpan.org/Public/Bug/Display.html?d=42793 Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=623681 Subject: ip_reverse() for IPv4 ignores prefixlen parameter The problem particularly occurs where there are a lot of zeros in the less significant quads. You can use a /number to force retention of those quads in the reversed address but the code was ignoring that instruction. There is some ambiguity over what should happen when the number of bits specified does not fall on a boundary. I have tested with Net::IP::XS and tried to follow what they do. Last-Update: 2011-05-11 --- /dev/null +++ b/t/reverse_ip.t @@ -0,0 +1,13 @@ +use Test::More tests=>4; +use Net::IP; + +my $obj = Net::IP->new('10.10.0.0/31'); +is($obj->reverse_ip, '0.10.10.in-addr.arpa.', 'reverse_ip'); +$obj->set('192.168.0.0/24'); +is($obj->reverse_ip, '0.168.192.in-addr.arpa.', 'reverse_ip'); +$obj->set('192.0.0.0/24'); +is($obj->reverse_ip, '0.0.192.in-addr.arpa.', 'reverse_ip'); +$obj->set('192.0.0.0/32'); +is($obj->reverse_ip, '0.0.0.192.in-addr.arpa.', 'reverse_ip'); + + --- a/IP.pm +++ b/IP.pm @@ -1769,12 +1769,13 @@ if ($ip_version == 4) { my @quads = split /\./, $ip; - my $no_quads = ($len / 8); + my $no_quads = 4 - int($len / 8); my @reverse_quads = reverse @quads; - while (@reverse_quads and $reverse_quads[0] == 0) { + while (@reverse_quads and $reverse_quads[0] == 0 and $no_quads > 0) { shift(@reverse_quads); + --$no_quads; } return join '.', @reverse_quads, 'in-addr', 'arpa.';
MIME-Version: 1.0
In-Reply-To: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <20090126092606.GA1159366 [...] snoopy.cc.univie.ac.at>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-9057-1309056087-1905.42793-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 65
Fix committed into 1.27 release. Thanks for the patch and report!


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.