summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-08-10 16:53:31 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-08-10 20:42:50 +0200
commita06eed0c0ec03bdbb0f97aede393b5c687041d88 (patch)
tree787f6e3aa94a660d58286314d02d8e13587567a7
parent0af3f493121f8eb5f71051303c5ee1a42a81fc6f (diff)
downloadphp-git-a06eed0c0ec03bdbb0f97aede393b5c687041d88.tar.gz
Fix bug #79944
Only return true from dns_get_mx if we actually found any MX record.
-rw-r--r--NEWS1
-rw-r--r--ext/standard/dns.c2
-rw-r--r--ext/standard/tests/network/getmxrr.phpt22
3 files changed, 15 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index ec597b4153..410b74a893 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ PHP NEWS
- Standard:
. Fixed bug #79930 (array_merge_recursive() crashes when called with array
with single reference). (Nikita)
+ . Fixed bug #79944 (getmxrr always returns true on Alpine linux). (Nikita)
- XML:
. Fixed bug #79922 (Crash after multiple calls to xml_parser_free()). (cmb)
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 705c8e4fad..56fb83eade 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -1114,7 +1114,7 @@ PHP_FUNCTION(dns_get_mx)
}
}
php_dns_free_handle(handle);
- RETURN_TRUE;
+ RETURN_BOOL(zend_hash_num_elements(Z_ARRVAL_P(weight_list)) != 0);
}
/* }}} */
#endif /* HAVE_FULL_DNS_FUNCS */
diff --git a/ext/standard/tests/network/getmxrr.phpt b/ext/standard/tests/network/getmxrr.phpt
index c4a15c52ce..52228685b0 100644
--- a/ext/standard/tests/network/getmxrr.phpt
+++ b/ext/standard/tests/network/getmxrr.phpt
@@ -10,15 +10,19 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
?>
--FILE--
<?php
-$domains = array( 'mx1.tests.php.net', 'mx2.tests.php.net' );
-foreach ( $domains as $domain )
-{
- if ( getmxrr( $domain, $hosts, $weights ) )
- {
- echo "Hosts: " . count( $hosts ) . ", weights: " . count( $weights ) . "\n";
- }
+$domains = array(
+ 'mx1.tests.php.net',
+ 'mx2.tests.php.net',
+ 'qa.php.net',
+);
+foreach ($domains as $domain) {
+ $result = getmxrr($domain, $hosts, $weights);
+ echo "Result: " . ($result ? "true" : "false")
+ . ", hosts: " . count( $hosts )
+ . ", weights: " . count( $weights ) . "\n";
}
?>
--EXPECT--
-Hosts: 1, weights: 1
-Hosts: 2, weights: 2
+Result: true, hosts: 1, weights: 1
+Result: true, hosts: 2, weights: 2
+Result: false, hosts: 0, weights: 0