Skip to content

Commit ba186d2

Browse files
committed
Fix bug #81618: dns_get_record failure on FreeBSD
when query for a record type fails. from fsbruva's insights.
1 parent 64fde17 commit ba186d2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ext/standard/dns.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,15 @@ PHP_FUNCTION(dns_get_record)
946946
n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer);
947947

948948
if (n < 0) {
949+
#if defined(HAVE_RES_NSEARCH)
950+
int r_h_errno = handle->res_h_errno;
951+
#endif
949952
php_dns_free_handle(handle);
953+
#if defined(HAVE_RES_NSEARCH)
954+
switch (r_h_errno) {
955+
#else
950956
switch (h_errno) {
957+
#endif
951958
case NO_DATA:
952959
case HOST_NOT_FOUND:
953960
continue;

ext/standard/tests/bug81618.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #81618: dns_get_record failure on FreeBSD
3+
--FILE--
4+
<?php
5+
$ret = dns_get_record('www.google.com', DNS_A + DNS_CNAME);
6+
7+
echo ($ret !== false && count($ret) > 0);
8+
9+
?>
10+
11+
--EXPECT--
12+
1

0 commit comments

Comments
 (0)