php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70027 dns_get_record does not behave the same between BSD and others
Submitted: 2015-07-08 16:03 UTC Modified: 2017-01-22 04:22 UTC
Votes:5
Avg. Score:4.0 ± 0.6
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (40.0%)
From: magicaltux at gmail dot com Assigned:
Status: No Feedback Package: Network related
PHP Version: 5.5.26 OS: FreeBSD 10.x
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-07-08 16:03 UTC] 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)

Patches

fix_70027.patch (last revision 2015-07-08 16:09 UTC by magicaltux at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-08 18:10 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2017-01-08 18:10 UTC] ab@php.net
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.
 [2017-01-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed May 22 09:01:25 2019 UTC