Bug #70027 [Opn->Fbk]: dns_get_record does not behave the same between BSD and others
Edit report at https://bugs.php.net/bug.php?id=70027&edit=1
ID: 70027
Updated by: ab@php.net
Reported by: magicaltux at gmail dot com
Summary: dns_get_record does not behave the same between BSD
and others
-Status: Open
+Status: Feedback
Type: Bug
Package: Network related
Operating System: FreeBSD 10.x
PHP Version: 5.5.26
Block user comment: N
Private report: N
New Comment:
Thanks for the patch. It's still not too late, but all PHP 5 branches are in security mode now.
Would you be up to adapt the patch for 7.x and add some test? I'd be able to test there and
apply.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-07-08 16:03:10] magicaltux at gmail dot com
Description:
------------
dns_get_record() allows retrieving one or multiple DNS records of one or multiple types.
When requesting for DNS_A + DNS_AAAA records but only A records are available, then only A records
are returned, except on BSD where instead an error is returned.
PHP will check h_errno for error, however it seems that FreeBSD 10.x or res_nsearch() will not
update this value, and will instead update res_h_errno in the handle.
In ext/standard/dns.c after the call to php_dns_search() I have added this debug line:
fprintf(stderr, "n=%d h_errno=%d statp->res_h_errno=%d\n", n, h_errno,
handle->res_h_errno);
The result when running the test script below was:
n=53 h_errno=0 statp->res_h_errno=1
n=-1 h_errno=0 statp->res_h_errno=4
So we could when HAVE_RES_NSEARCH is defined do the switch not on h_errno, but
handle->res_h_errno.
Test script:
---------------
var_dump(dns_get_record("www.asahi-net.or.jp", DNS_A + DNS_AAAA));
Expected result:
----------------
array(1) {
[0]=>
array(5) {
["host"]=>
string(19) "www.asahi-net.or.jp"
["class"]=>
string(2) "IN"
["ttl"]=>
int(40667)
["type"]=>
string(1) "A"
["ip"]=>
string(13) "202.224.39.34"
}
}
Actual result:
--------------
Warning: dns_get_record(): DNS Query failed in test.php on line 2
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70027&edit=1
Thread (3 messages)