Skip to content

Commit 731f782

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 731f782

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ext/standard/dns.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,13 @@ 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+
int r_h_errno = handle->res_h_errno;
949950
php_dns_free_handle(handle);
951+
#if defined(HAVE_RES_NSEARCH)
952+
switch (r_h_errno) {
953+
#else
950954
switch (h_errno) {
955+
#endif
951956
case NO_DATA:
952957
case HOST_NOT_FOUND:
953958
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)