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:7
Avg. Score:4.3 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:0 (0.0%)
Same OS:3 (42.9%)
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: magicaltux at gmail dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 02:01:29 2024 UTC