ID: 34938
Updated by: [EMAIL PROTECTED]
Reported By: php at ter dot dk
-Status: Open
+Status: Assigned
Bug Type: Network related
Operating System: Linux 2.4 debian sarge
PHP Version: 5.1.0RC3
-Assigned To:
+Assigned To: tony2001
Previous Comments:
------------------------------------------------------------------------
[2005-10-21 05:14:48] php at ter dot dk
Please be aware of line breaks added by the bug system.
------------------------------------------------------------------------
[2005-10-21 05:08:11] 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
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34938&edit=1