Skip to content

Commit 4a26563

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix bug #81618: Correct dns_get_record on FreeBSD
2 parents 292d76d + 45f5228 commit 4a26563

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ PHP NEWS
1919
. Fixed bug #81587 (MultipleIterator Segmentation fault w/ SimpleXMLElement
2020
attached). (Nikita)
2121

22+
- Standard:
23+
. Fixed bug #81618 (dns_get_record fails on FreeBSD for missing type).
24+
(fsbruva)
25+
2226
18 Nov 2021, PHP 8.0.13
2327

2428
- Core:

ext/standard/dns.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ PHP_FUNCTION(dns_get_record)
798798
zend_long type_param = PHP_DNS_ANY;
799799
zval *authns = NULL, *addtl = NULL;
800800
int type_to_fetch;
801+
int dns_errno;
801802
#if defined(HAVE_DNS_SEARCH)
802803
struct sockaddr_storage from;
803804
uint32_t fromsize = sizeof(from);
@@ -946,8 +947,9 @@ PHP_FUNCTION(dns_get_record)
946947
n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer);
947948

948949
if (n < 0) {
950+
dns_errno = php_dns_errno(handle);
949951
php_dns_free_handle(handle);
950-
switch (h_errno) {
952+
switch (dns_errno) {
951953
case NO_DATA:
952954
case HOST_NOT_FOUND:
953955
continue;

ext/standard/php_dns.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
((int)dns_search(res, dname, class, type, (char *) answer, anslen, (struct sockaddr *)&from, &fromsize))
2525
#define php_dns_free_handle(res) \
2626
dns_free(res)
27+
#define php_dns_errno(handle) h_errno
2728

2829
#elif defined(HAVE_RES_NSEARCH)
2930
#define php_dns_search(res, dname, class, type, answer, anslen) \
@@ -37,11 +38,13 @@
3738
res_nclose(res); \
3839
php_dns_free_res(res)
3940
#endif
41+
#define php_dns_errno(handle) handle->res_h_errno
4042

4143
#elif defined(HAVE_RES_SEARCH)
4244
#define php_dns_search(res, dname, class, type, answer, anslen) \
4345
res_search(dname, class, type, answer, anslen)
4446
#define php_dns_free_handle(res) /* noop */
47+
#define php_dns_errno(handle) h_errno
4548

4649
#endif
4750

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

0 commit comments

Comments
 (0)