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

Bug #3851 IPv4-mapped/compatible IPv6 uncompress bug
Submitted: 2005-03-16 22:19 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  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 44 - 16 = ?

 
 [2005-03-16 22: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 09:12 UTC] alexmerz at php dot net
I will deal with it during the next days.
 [2005-03-19 20: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