From ecab534aa89f8d125a7f27d445dade0c8b024b83 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Mon, 14 May 2007 14:38:29 +0000 Subject: [PATCH] MFB: Fixed bug #41347 (checkdnsrr() segfaults on empty hostname). --- ext/standard/dns.c | 6 ++++++ ext/standard/tests/network/bug41347.phpt | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 ext/standard/tests/network/bug41347.phpt 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-- + +--FILE-- + +--EXPECTF-- +Warning: dns_check_record(): Host cannot be empty in %s on line %d +bool(false) -- 2.40.0