Subject: | reverse_ip removes too many quads from certain v4 IP's |
Date: | Wed, 14 May 2014 16:03:22 +1000 |
To: | "bug-Net-IP [...] rt.cpan.org" <bug-Net-IP [...] rt.cpan.org> |
From: | "Beeson, Ayden" <ABeeson [...] csu.edu.au> |
I have found a bug in Net::IP where reverse_ip is taking off too many 0's from IP addresses.
An example is 10.0.0.1 - I want to get the reverse subnet for it, (assuming it is a /24 network you are working with) sending reverse_ip 10.0.0.1/24 results in 10.in-addr.arpa.
I have checked the code and found that the problem is the way the v4 addresses are being handled, there is a while that simply keeps looking for zeroes and removes them until there are no more zeroes at the start of the reverse.
while (@reverse_quads and $reverse_quads[0] == 0) {
shift(@reverse_quads);
}
It also appears that a length calculation is done to get the number of quads but it's never checked. Changing the while to this:
while (@reverse_quads and $reverse_quads[0] == 0 and scalar(@reverse_quads) > $no_quads) {
shift(@reverse_quads);
}
Will fix the problem in the most graceful way I could come up with quickly.
[cid:csu-logo66bf.bmp]<http://www.csu.edu.au/>
| ALBURY-WODONGA | BATHURST | CANBERRA | DUBBO | GOULBURN | MELBOURNE | ONTARIO | ORANGE | PORT MACQUARIE | SYDNEY | WAGGA WAGGA |
Show quoted text
________________________________
LEGAL NOTICE
This email (and any attachment) is confidential and is intended for the use of the addressee(s) only. If you are not the intended recipient of this email, you must not copy, distribute, take any action in reliance on it or disclose it to anyone. Any confidentiality is not waived or lost by reason of mistaken delivery. Email should be checked for viruses and defects before opening. Charles Sturt University (CSU) does not accept liability for viruses or any consequence which arise as a result of this email transmission. Email communications with CSU may be subject to automated email filtering, which could result in the delay or deletion of a legitimate email before it is read at CSU. The views expressed in this email are not necessarily those of CSU.
Charles Sturt University in Australia<http://www.csu.edu.au> The Grange Chancellery, Panorama Avenue, Bathurst NSW Australia 2795 (ABN: 83 878 708 551; CRICOS Provider Number: 00005F (National)). TEQSA Provider Number: PV12018
Charles Sturt University in Ontario<http://www.charlessturt.ca/> 860 Harrington Court, Burlington Ontario Canada L7N 3N4 Registration: www.peqab.ca<http://www.peqab.ca>
Consider the environment before printing this email.
Disclaimer added by CodeTwo Exchange Rules 2007
www.codetwo.com<http://www.codetwo.com>