diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 41b98424edb60..ca3e05e08152a 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -946,8 +946,15 @@ PHP_FUNCTION(dns_get_record) n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer); if (n < 0) { +#if defined(HAVE_RES_NSEARCH) + int r_h_errno = handle->res_h_errno; +#endif php_dns_free_handle(handle); +#if defined(HAVE_RES_NSEARCH) + switch (r_h_errno) { +#else switch (h_errno) { +#endif case NO_DATA: case HOST_NOT_FOUND: continue; diff --git a/ext/standard/tests/bug81618.phpt b/ext/standard/tests/bug81618.phpt new file mode 100644 index 0000000000000..fbdb29e90eee3 --- /dev/null +++ b/ext/standard/tests/bug81618.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #81618: dns_get_record failure on FreeBSD +--FILE-- + 0); + +?> + +--EXPECT-- +1