]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #41347 (checkdnsrr() segfaults on empty hostname).
authorScott MacVicar <scottmac@php.net>
Mon, 14 May 2007 14:38:29 +0000 (14:38 +0000)
committerScott MacVicar <scottmac@php.net>
Mon, 14 May 2007 14:38:29 +0000 (14:38 +0000)
ext/standard/dns.c
ext/standard/tests/network/bug41347.phpt [new file with mode: 0644]

index 60cba0539fb86fbc7173ea77fbd6b998590db13b..f99e59e92b81ce7a626acc2054941fbbe18bc82a 100644 (file)
@@ -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 (file)
index 0000000..6bb363e
--- /dev/null
@@ -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)