Bug #17918 [Asn->Csd]: AAAA addresses without '::' fail to be created
| From: | bate@php.net | Date: | Wed, 03 Nov 2010 10:04:12 +0000 |
| Subject: | Bug #17918 [Asn->Csd]: AAAA addresses without '::' fail to be created | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-5018@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=17918&edit=1
ID: 17918
Updated by: bate@php.net
Reported By: Mike dot Mitchell at sas dot com
Summary: AAAA addresses without '::' fail to be created
-Status: Assigned
+Status: Closed
Type: Bug
Package: Net_DNS
Operating System: Redhat ES 3.0
Package Version: 1.0.5
PHP Version: 5.2.12
Assigned To: bate
Roadmap Versions:
New Comment:
-Status: Assigned
+Status: Closed
This bug has been fixed in SVN.
If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).
If this was a problem with the pear.php.net website, the change should
be live shortly.
Otherwise, the fix will appear in the package's next release.
Thank you for the report and for helping us make PEAR better.
Previous Comments:
------------------------------------------------------------------------
[2010-10-08 16:07:36] doconnor
-Assigned To:
+Assigned To: bate
------------------------------------------------------------------------
[2010-10-01 14:24:02] dundakitty
Added #patch bug:17918;patch:AAAA.patch;revision:1285943042;.
------------------------------------------------------------------------
[2010-10-01 06:37:05] bate
can you provide a diff to the latest svn version to fix this issue?
------------------------------------------------------------------------
[2010-09-30 14:42:57] dundakitty
Description:
------------
Net_DNS_RR::factory fails to create the proper update record when passed
an AAAA type and an address without a '::', such as
'fd07:af30:a3fc:a10:209:3dff:fe13:48a8'.
The preg_match pattern in ipv6_compress is the problem. The pattern
'/^([0-9A-F]{0,4}:){0,7}(:[0-9A-F]{0,4}){0,7}$/i'
only matches addresses containing '::'.
I am now using the following code to work around the problem.
/* Net_DNS_RR_AAAA::ipv6_compress($addr) {{{ */
function ipv6_compress($addr)
{
$numparts = count(explode(':', $addr));
if ($numparts < 3 || $numparts > 8 ) {
/* Non-sensical IPv6 address */
return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);
}
if (strpos($addr, '::') !== false) {
if
(!preg_match('/^([0-9A-F]{0,4}:){0,7}(:[0-9A-F]{0,4}){0,7}$/i', $addr))
{
return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);
}
/* First we have to normalize the address, turn :: into
:0:0:0:0: */
$filler = str_repeat(':0', 9 - $numparts) . ':';
if (substr($addr, 0, 2) == '::') {
$filler = "0$filler";
}
if (substr($addr, -2, 2) == '::') {
$filler .= '0';
}
$addr = str_replace('::', $filler, $addr);
} else {
if (!preg_match('/^([0-9A-F]{0,4}:){7}[0-9A-F]{0,4}$/i',
$addr)) {
return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);
}
}
$aparts = explode(':', $addr);
return pack('n8', hexdec($aparts[0]), hexdec($aparts[1]),
hexdec($aparts[2]), hexdec($aparts[3]),
hexdec($aparts[4]), hexdec($aparts[5]),
hexdec($aparts[6]), hexdec($aparts[7]));
}
/* }}} */
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=17918&edit=1