|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-21 05:08 UTC] php at ter dot dk
Description:
------------
(the error also occurs in PHP5.0.5)
dns_get_record() results in strange behaviour when supplied with long hostnames, e.g.:
$ host -t mx 0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk
0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk MX 10 mail.0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk
.. but:
$ php -v
PHP 5.0.5-1.dotdeb.1 (cli) (built: Sep 7 2005 10:07:31)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.5, Copyright (c) 1998-2004 Zend Technologies
$ php -r 'var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));'
array(0) {
}
$ ~/dev/php-5.1.0RC3/sapi/cli/php -v
PHP 5.1.0RC3 (cli) (built: Oct 21 2005 04:40:34)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2005 Zend Technologies
$ ~/dev/php-5.1.0RC3/sapi/cli/php -r 'var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));'
array(0) {
}
(yes, the domain name is valid and has a MX entry)
Furthermore, strange results arrive when dns_get_record() is called with long hostnames several times after a succesful lookup (for at shorter hostname). According to var_dump(), dns_get_record() loops between returning an array with an int, a recursive array and NULL.
The error is not restricted to DNS_MX - same result will show up for e.g. DNS_A and DNS_NS requests.
Before suspecting the output of dns_get_record() I was baffled when php actually segfaulted when beginning a foreach()-loop with the return value of dns_get_record(). I suppose it happened when foreach() was supplied with a recursion.
Reproduce code:
---------------
<?php
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
var_dump(dns_get_record("php.net",DNS_MX));
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
var_dump(dns_get_record("0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk",DNS_MX));
?>
Expected result:
----------------
array(1) {
[0]=>
array(6) {
["host"]=>
string(7) "0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk"
["type"]=>
string(2) "MX"
["pri"]=>
int(10)
["target"]=>
string(12) "mail.0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0.dk"
["class"]=>
string(2) "IN"
["ttl"]=>
int(127779)
}
}
(a couple of times)
Actual result:
--------------
array(0) {
}
array(0) {
}
array(2) {
[0]=>
array(6) {
["host"]=>
string(7) "php.net"
["type"]=>
string(2) "MX"
["pri"]=>
int(5)
["target"]=>
string(12) "osu1.php.net"
["class"]=>
string(2) "IN"
["ttl"]=>
int(63337)
}
[1]=>
array(6) {
["host"]=>
string(7) "php.net"
["type"]=>
string(2) "MX"
["pri"]=>
int(15)
["target"]=>
string(15) "smtp.osuosl.org"
["class"]=>
string(2) "IN"
["ttl"]=>
int(63337)
}
}
array(1) {
[0]=>
int(16384)
}
array(1) {
[0]=>
array(1) {
[0]=>
*RECURSION*
}
}
array(1) {
[0]=>
NULL
}
array(1) {
[0]=>
int(16384)
}
array(1) {
[0]=>
array(1) {
[0]=>
*RECURSION*
}
}
array(1) {
[0]=>
NULL
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
I think we have a major regression in latest snaps (same result in php5-200510232030 and php5-200510232230) where the return values are pretty strange for any host checked, even short hosts, e.g.: $ ~/dev/php5-200510232230/sapi/cli/php -r 'var_dump(dns_get_record("php.net",DNS_MX));' array(1) { [0]=> array(6) { ["host"]=> string(7) "php.net" ["type"]=> string(2) "MX" ["pri"]=> int(19) ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65537) } } $ ~/dev/php5-200510232230/sapi/cli/php -r 'var_dump(dns_get_record("php.net",DNS_A));' array(1) { [0]=> array(5) { ["host"]=> string(7) "php.net" ["type"]=> string(1) "A" ["ip"]=> string(10) "0.4.64.246" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } } $ ~/dev/php5-200510232230/sapi/cli/php -r 'var_dump(dns_get_record("php.net",DNS_NS));' array(4) { [0]=> array(5) { ["host"]=> string(7) "php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } [1]=> array(5) { ["host"]=> string(37) "\003ns2\007easydns\003com\000.php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } [2]=> array(5) { ["host"]=> string(20) "\003ns1\192).php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } [3]=> array(5) { ["host"]=> string(24) "\007remote1\192).php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } } It seems like there is some kind of offset error (e.g. octet 1 and 2 in the IP address for the A lookup is presented as octet 3 and 4) On the lighter side the long hostnames behave in the new way as well. I'm sorry if I'm just impatient. - Peter BrodersenSorry, still no dice with latest snapshot; php5-200510250230: $ ~/dev/php5-200510250230/sapi/cli/php -r 'var_dump(dns_get_record("php.net",DNS_NS));' array(4) { [0]=> array(5) { ["host"]=> string(7) "php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } [1]=> array(5) { ["host"]=> string(37) "\003ns2\007easydns\003com\000.php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } [2]=> array(5) { ["host"]=> string(24) "\007remote1\192).php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } [3]=> array(5) { ["host"]=> string(20) "\003ns1\192).php.net" ["type"]=> string(2) "NS" ["target"]=> string(0) "" ["class"]=> string(2) "IN" ["ttl"]=> int(65536) } } - Peter Brodersen