PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_DNS » Bug #3236

PATCH [fixes bug 3175]

Details

Submitted2005-01-19 03:32 UTC
Frommark at everytruckjob dot com
StatusClosed
PackageNet_DNS
PHP VersionIrrelevant
OSlinux
Roadmaps(Not assigned)

Comments

[2005-01-19 03:32 UTC] mark at everytruckjob dot com

Description:
------------
Please find attached a patch that fixes bug 3175 (incorrect AAAA record data returned). The patch also includes two white space fixes. Without the patch, records that include "*0:0:" have it replaced with "::", so all the following records return incorrect data.

kite-www.ripe.net
2001:610:240:0:a843::8 (correct)
2001:610:24::a843::8 (result)

munnari.OZ.AU
2001:388:c02:4000::1:21 (correct)
2001:388:c02:400::1:21 (result)

ns3.verio.net
2001:728:0:7000::200 (correct)
2001:728:0:700::200 (result)

Reproduce code:
---------------
--- pear/Net_DNS/DNS/RR/AAAA.php 2003-05-06 13:04:28.000000000 -0500
+++ newpear/Net_DNS/DNS/RR/AAAA.php 2005-01-18 21:06:32.000000000 -0600
@@ -50,7 +50,7 @@
$this->rdata = $rro->rdata;

if ($offset) {
- $this->address = Net_DNS_RR_AAAA::ipv6_decompress(substr($this->rdata, 0, $this->rdlength));
+ $this->address = Net_DNS_RR_AAAA::ipv6_decompress(substr($this->rdata, 0, $this->rdlength));
} else {
if (strlen($data)) {
if (count($adata = explode(':', $data, 8)) >= 3) {
@@ -75,7 +75,7 @@
/* Net_DNS_RR_AAAA::rr_rdata($packet, $offset) {{{ */
function rr_rdata($packet, $offset)
{
- return Net_DNS_RR_AAAA::ipv6_compress($this->address);
+ return Net_DNS_RR_AAAA::ipv6_compress($this->address);
}

/* }}} */
@@ -112,18 +112,19 @@
/* Must be 8 shorts long */
return '::';
}
- $a = unpack('n8b', $pack);
- foreach($a as $idx => $value)
- $a[$idx] = dechex($value);
- $addr = implode(':', $a);
- /* Shorthand the first :0:0:0: set into a :: */
+ $a = unpack('n8', $pack);
+ $addr = vsprintf("%x:%x:%x:%x:%x:%x:%x:%x", $a);
+ /* Shorthand the first :0:0: set into a :: */
/* TODO: Make this is a single replacement pattern */
- if (substr($addr, -4, 4) == ':0:0') {
+ if (substr($addr, -4) == ':0:0') {
return preg_replace('/((:0){2,})$/', '::', $addr);
+ } elseif (substr($addr, 0, 4) == '0:0:') {
+ return '0:0:'. substr($addr, 4);
} else {
- return preg_replace('/(:?(0:){2,})/', '::', $addr);
+ return preg_replace('/(:(0:){2,})/', '::', $addr);
}
}
+
/* }}} */
}
/* }}} */