Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Fixed bug #71273 A wrong ext directory setup in php.ini leads to crash
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Jan 5, 2016
1 parent 654c8ae commit 9a07245
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
19 changes: 16 additions & 3 deletions main/main.c
Expand Up @@ -723,9 +723,20 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ

if (PG(html_errors)) {
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL);
/* Retry with substituting invalid chars on fail. */
if (!replace_buffer) {
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, NULL);
}

efree(buffer);
buffer = ZSTR_VAL(replace_buffer);
buffer_len = (int)ZSTR_LEN(replace_buffer);

if (replace_buffer) {
buffer = ZSTR_VAL(replace_buffer);
buffer_len = (int)ZSTR_LEN(replace_buffer);
} else {
buffer = "";
buffer_len = 0;
}
}

/* which function caused the problem if any at all */
Expand Down Expand Up @@ -878,7 +889,9 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
if (replace_buffer) {
zend_string_free(replace_buffer);
} else {
efree(buffer);
if (buffer_len > 0) {
efree(buffer);
}
}

php_error(type, "%s", message);
Expand Down
21 changes: 21 additions & 0 deletions tests/basic/bug71273.phpt
@@ -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==

0 comments on commit 9a07245

Please sign in to comment.