diff options
-rw-r--r-- | ext/standard/dns_win32.c | 13 | ||||
-rw-r--r-- | ext/standard/tests/network/dns_check_record_error_conditions.phpt | 19 | ||||
-rw-r--r-- | ext/standard/tests/network/dns_get_record_error_conditions.phpt | 31 |
3 files changed, 56 insertions, 7 deletions
diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c index 838a40c94e..afeab23a08 100644 --- a/ext/standard/dns_win32.c +++ b/ext/standard/dns_win32.c @@ -124,8 +124,8 @@ PHP_FUNCTION(dns_check_record) else if (!strcasecmp("NAPTR", rectype)) type = DNS_TYPE_NAPTR; else if (!strcasecmp("A6", rectype)) type = DNS_TYPE_A6; else { - php_error_docref(NULL, E_WARNING, "Type '%s' not supported", rectype); - RETURN_FALSE; + zend_argument_value_error(2, "must be a valid DNS record type"); + RETURN_THROWS(); } } @@ -373,14 +373,13 @@ PHP_FUNCTION(dns_get_record) if (!raw) { if ((type_param & ~PHP_DNS_ALL) && (type_param != PHP_DNS_ANY)) { - php_error_docref(NULL, E_WARNING, "Type '%ld' not supported", type_param); - RETURN_FALSE; + zend_argument_value_error(2, "must be a DNS_* constant"); + RETURN_THROWS(); } } else { if ((type_param < 1) || (type_param > 0xFFFF)) { - php_error_docref(NULL, E_WARNING, - "Numeric DNS record type must be between 1 and 65535, '%ld' given", type_param); - RETURN_FALSE; + zend_argument_value_error(2, "must be between 1 and 65535 when argument #5 ($raw) is true"); + RETURN_THROWS(); } } diff --git a/ext/standard/tests/network/dns_check_record_error_conditions.phpt b/ext/standard/tests/network/dns_check_record_error_conditions.phpt new file mode 100644 index 0000000000..dae0bfb375 --- /dev/null +++ b/ext/standard/tests/network/dns_check_record_error_conditions.phpt @@ -0,0 +1,19 @@ +--TEST-- +dns_check_record() error conditions +--FILE-- +<?php +try { + dns_check_record(''); +} catch (\ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + // A random DNS Mode + dns_check_record('php.net', 15263480); +} catch (\ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +?> +--EXPECT-- +dns_check_record(): Argument #1 ($hostname) cannot be empty +dns_check_record(): Argument #2 ($type) must be a valid DNS record type diff --git a/ext/standard/tests/network/dns_get_record_error_conditions.phpt b/ext/standard/tests/network/dns_get_record_error_conditions.phpt new file mode 100644 index 0000000000..6506aca410 --- /dev/null +++ b/ext/standard/tests/network/dns_get_record_error_conditions.phpt @@ -0,0 +1,31 @@ +--TEST-- +dns_get_record() error conditions +--FILE-- +<?php +try { + // A random DNS Mode + dns_get_record('php.net', 15263480); +} catch (\ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + // DNS Mode 0 + $auth = []; + $additional = []; + dns_get_record('php.net', 0, $auth, $additional, true); +} catch (\ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + // A random DNS Mode + $auth = []; + $additional = []; + dns_get_record('php.net', 15263480, $auth, $additional, true); +} catch (\ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +?> +--EXPECT-- +dns_get_record(): Argument #2 ($type) must be a DNS_* constant +dns_get_record(): Argument #2 ($type) must be between 1 and 65535 when argument #5 ($raw) is true +dns_get_record(): Argument #2 ($type) must be between 1 and 65535 when argument #5 ($raw) is true |