Bug #70027 [NEW]: dns_get_record does not behave the same between BSD and others
| From: | magicaltux at gmail dot com | Date: | Wed, 08 Jul 2015 16:03:10 +0000 |
| Subject: | Bug #70027 [NEW]: dns_get_record does not behave the same between BSD and others | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-194222@lists.php.net to get a copy of this message | ||
From: magicaltux at gmail dot com
Operating system: FreeBSD 10.x
PHP version: 5.5.26
Package: Network related
Bug Type: Bug
Bug description:dns_get_record does not behave the same between BSD and others
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 bug report at https://bugs.php.net/bug.php?id=70027&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70027&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70027&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70027&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70027&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70027&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70027&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70027&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70027&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70027&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70027&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70027&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70027&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70027&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70027&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70027&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70027&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70027&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70027&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70027&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70027&r=mysqlcfg