]> granicus.if.org Git - php/commitdiff
backport 9a07245b728714de09361ea16b9c6fcf70cb5685 from 7.0
authorAnatol Belski <ab@php.net>
Mon, 11 Jan 2016 19:37:46 +0000 (20:37 +0100)
committerAnatol Belski <ab@php.net>
Mon, 11 Jan 2016 19:37:46 +0000 (20:37 +0100)
main/main.c
tests/basic/bug71273.phpt [new file with mode: 0644]

index cc21fbd539a5d9b3119dfae77edee19da9ebf483..877507d8b88bc446fb44ec76f030f2fd8d2863d7 100644 (file)
@@ -788,9 +788,20 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
        if (PG(html_errors)) {
                size_t len;
                char *replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
+
+               if (!replace || len < 1) {
+                       replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, NULL TSRMLS_CC);
+               }
+
                efree(buffer);
-               buffer = replace;
-               buffer_len = len;
+
+               if (replace) {
+                       buffer = replace;
+                       buffer_len = len;
+               } else {
+                       buffer = "";
+                       buffer_len = 0;
+               }
        }
 
        /* which function caused the problem if any at all */
@@ -935,7 +946,9 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
                        zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) &tmp, sizeof(zval *), NULL);
                }
        }
-       str_efree(buffer);
+       if (buffer_len > 0) {
+               str_efree(buffer);
+       }
 
        php_error(type, "%s", message);
        efree(message);
diff --git a/tests/basic/bug71273.phpt b/tests/basic/bug71273.phpt
new file mode 100644 (file)
index 0000000..d0cd725
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #71273 A wrong ext directory setup in php.ini leads to crash
+--SKIPIF--
+<?php
+       if ("cli" != php_sapi_name()) {
+               die("skip CLI only");
+       }
+?>
+--FILE--
+<?php
+       /* NOTE this file is required to be encoded in iso-8859-1 */
+
+       $cmd = getenv('TEST_PHP_EXECUTABLE') . " -n -d html_errors=on -d extension_dir=a/é/w -d extension=php_kartoffelbrei.dll -v 2>&1";
+       $out = shell_exec($cmd);
+
+       var_dump(preg_match(",.+a[\\/].+[\\/]w.php_kartoffelbrei.dll.+,s", $out));
+?>
+==DONE==
+--EXPECTF--
+int(1)
+==DONE==