diff options
| author | Scott MacVicar <scottmac@php.net> | 2007-05-10 13:16:54 +0000 |
|---|---|---|
| committer | Scott MacVicar <scottmac@php.net> | 2007-05-10 13:16:54 +0000 |
| commit | e7577d57cdae2e702961455bbe25ff02452f2ea0 (patch) | |
| tree | 1542f0e03c8ee5b6a31c9d1d0abc44ac93993ac5 /ext/standard | |
| parent | c69b76dc521590796c274ae43ed986942a216949 (diff) | |
| download | php-git-e7577d57cdae2e702961455bbe25ff02452f2ea0.tar.gz | |
Fixed bug #41347 (checkdnsrr() segfaults on empty hostname).
Diffstat (limited to 'ext/standard')
| -rw-r--r-- | ext/standard/dns.c | 12 | ||||
| -rw-r--r-- | ext/standard/tests/network/bug41347.phpt | 19 |
2 files changed, 31 insertions, 0 deletions
diff --git a/ext/standard/dns.c b/ext/standard/dns.c index fd40806167..4e4242458b 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -264,6 +264,12 @@ PHP_FUNCTION(dns_check_record) } type = T_MX; convert_to_string_ex(arg1); + + if (Z_STRLEN_PP(arg1) == 0) + { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host cannot be empty"); + RETURN_FALSE; + } break; case 2: @@ -273,6 +279,12 @@ PHP_FUNCTION(dns_check_record) convert_to_string_ex(arg1); convert_to_string_ex(arg2); + if (Z_STRLEN_PP(arg1) == 0 || Z_STRLEN_PP(arg2) == 0) + { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host and type cannot be empty"); + RETURN_FALSE; + } + if (!strcasecmp("A", Z_STRVAL_PP(arg2))) type = T_A; else if (!strcasecmp("NS", Z_STRVAL_PP(arg2))) type = DNS_T_NS; else if (!strcasecmp("MX", Z_STRVAL_PP(arg2))) type = DNS_T_MX; diff --git a/ext/standard/tests/network/bug41347.phpt b/ext/standard/tests/network/bug41347.phpt new file mode 100644 index 0000000000..ef93a202bc --- /dev/null +++ b/ext/standard/tests/network/bug41347.phpt @@ -0,0 +1,19 @@ +--TEST-- +dns_check_record() segfault with empty host +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('No windows support'); +} +?> +--FILE-- +<?php +var_dump(dns_check_record('')); +var_dump(dns_check_record('', '')); +?> +--EXPECTF-- +Warning: dns_check_record(): Host cannot be empty in %s on line %d +bool(false) + +Warning: dns_check_record(): Host and type cannot be empty in %s on line %d +bool(false) |
