Bug #81618 [NEW]: dns_get_record fails on FreeBSD for missing type
From: fsbruva at yahoo dot com
Operating system: FreeBSD 12.x
PHP version: Irrelevant
Package: *Network Functions
Bug Type: Bug
Bug description:dns_get_record fails on FreeBSD for missing type
Description:
------------
On modern FreeBSD, res_nsearch() does not directly set a value for
h_errno, but rather, the last h_errno value is stored as res_h_errno
within the handle (statp->res_h_errno). Thus, in ext/standard/dns.c,
within the definition for dns_get_record, the switch case at
https://github.com/php/php-src/blob/master/ext/standard/dns.c#L981
doesn't properly categorize or catch error conditions for a particular
query. Namely, instead of properly continuing to try the next record for
NO_DATA or HOST_NOT_FOUND responses, the function completely fails and
returns false. In my (limited) testing of this issue on Ubuntu, h_errno
always equaled statp->res_h_errno, so I don't believe this fix needs to
be OS dependent.
This bug was originally reported in php 5.5.26, and is confirmed to
affect 7.3.32, 7.4.25 and 8.0.12, on FreeBSD 12.2-RELEASE on amd64. See:
https://bugs.php.net/bug.php?id=70027
Test script:
---------------
php -r "var_dump(dns_get_record('www.google.com', DNS_A + DNS_CNAME));"
Expected result:
----------------
There is no CNAME record for www.google.com, so we'd only see a result
for the A record.
array(1) {
[0]=>
array(5) {
["host"]=>
string(14) "www.google.com"
["class"]=>
string(2) "IN"
["ttl"]=>
int(66)
["type"]=>
string(1) "A"
["ip"]=>
string(12) "142.251.45.4"
}
}
Actual result:
--------------
Warning: dns_get_record(): DNS Query failed in Command line code on line
1
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=81618&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81618&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81618&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81618&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81618&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81618&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81618&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81618&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81618&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81618&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81618&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81618&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81618&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81618&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81618&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81618&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81618&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81618&r=mysqlcfg
Thread (5 messages)
- fsbruva at yahoo dot com