Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2b2

Bug #3851 IPv4-mapped/compatible IPv6 uncompress bug
Submitted: 2005-03-16 17:19 UTC Modified: 2005-03-19 15:48 UTC
From: dtaylor at jasi dot com Assigned: alexmerz
Status: Closed Package: Net_IPv6
PHP Version: 4.3.10 OS: SUSE Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-03-16 17:19 UTC] dtaylor at jasi dot com
Description: ------------ Uncompressing an IPv4-mapped/compatible IPv6 address produced an address with 9 octets. The problem manifiests itself when splitting on '::' and counting the number of remaining ':'. An IPv4 address is actually 2 octets in an IPv6 address. This was not taken into account. The code below fixes that problem. Reproduce code: --------------- function Uncompress($ip) { ... if(""==$ip2) { $c2 = -1; } else { $pos = 0; if(0 < ($pos = substr_count($ip2, ':'))) { $c2 = $pos; } else { $c2 = 0; } } //************************************************ // Account for ::FFFF:127.0.0.1 and ::127.0.0.1 // (IPv4-mapped/compatible IPv6 addresses) if(strstr($ip2, '.')) { $c2++; } //************************************************ if(-1 == $c1 && -1 == $c2) { // :: $uip = "0:0:0:0:0:0:0:0"; } else if(-1==$c1) { // ::xxx $fill = str_repeat('0:', 7-$c2); $uip = str_replace('::', $fill, $uip); } else if(-1==$c2) { // xxx:: $fill = str_repeat(':0', 7-$c1); $uip = str_replace('::', $fill, $uip); } else { // xxx::xxx $fill = str_repeat(':0:', 6-$c2-$c1); $uip = str_replace('::', $fill, $uip); $uip = str_replace('::', ':', $uip); } } return $uip; }

Comments

 [2005-03-17 04:12 UTC] alexmerz at php dot net
I will deal with it during the next days.
 [2005-03-19 15:48 UTC] alexmerz at php dot net
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Net_IPv6