diff options
-rw-r--r-- | ext/standard/dns.c | 6 | ||||
-rw-r--r-- | ext/standard/tests/network/bug41347.phpt | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 60cba0539f..f99e59e92b 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -263,6 +263,12 @@ PHP_FUNCTION(dns_check_record) return; } + if (hostname_len == 0) + { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host cannot be empty"); + RETURN_FALSE; + } + if (rectype) { if (!strcasecmp("A", rectype)) type = T_A; else if (!strcasecmp("NS", rectype)) type = DNS_T_NS; diff --git a/ext/standard/tests/network/bug41347.phpt b/ext/standard/tests/network/bug41347.phpt new file mode 100644 index 0000000000..6bb363ecab --- /dev/null +++ b/ext/standard/tests/network/bug41347.phpt @@ -0,0 +1,15 @@ +--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('')); +?> +--EXPECTF-- +Warning: dns_check_record(): Host cannot be empty in %s on line %d +bool(false) |