h0arry / ipaddr-py

Automatically exported from code.google.com/p/ipaddr-py
0 stars 0 forks source link

Wrong output from IPv6Address.teredo #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
2. import ipaddr
1. ipaddr.IPv6Address('2001:0:5ef5:79fd:0:59d:a0e5:ba1').teredo

What is the expected output? What do you see instead?
Expected output should be: (IPv4Address('94.245.121.253'), 
IPv4Address('95.26.244.94'))
where it actually is: (IPv4Address('94.245.121.253'), 
IPv4Address('245.241.164.94')) - clearly wrong.
Compare with 
http://isc.sans.edu/tools/ipv6.html?ip=2001:0:5ef5:79fd:0:59d:a0e5:ba1&submit=Su
bmit

What version of the product are you using? On what operating system?
Tested on Mac OS X (2.1.7, Python 2.6.1) and Fedora (2.1.7, Python 2.7).

Apparently that's caused by _explode_shorthand_ip_string() not correctly 
expanding bits (e.g., 'ba1' should be expanded to '0ba1').

From ipaddr.py#1766: IPv4Address(int(''.join(bits[6:]), 16) ^ 0xFFFFFFFF)
bits[6:] = ['a0e5', 'ba1']

Last part correctly expanded:
>>> print IPv4Address(int(''.join(['a0e5','0ba1']), 16) ^ 0xffffffff)
95.26.244.94

Original issue reported on code.google.com by anaconda...@gmail.com on 5 Feb 2011 at 10:02

GoogleCodeExporter commented 9 years ago
I've uploaded a patch that fixes this issue [1] by making sure that anything 
leaving _explode_shorthand_ip_string() is fully expanded, even if 
_is_shorthand_ip() returns False.

[1] http://codereview.appspot.com/4119059

Original comment by anaconda...@gmail.com on 6 Feb 2011 at 3:03

GoogleCodeExporter commented 9 years ago
thanks for the report. I'd consider this an _is_shorthand_ip bug; I've got a 
patch out to fix this (http://codereview.appspot.com/4170047/)

Original comment by pmo...@google.com on 13 Feb 2011 at 6:08

GoogleCodeExporter commented 9 years ago
fixed in r218

Original comment by pmo...@google.com on 20 Feb 2011 at 5:57