jani Fri Nov 16 12:26:05 2007 UTC
Added files:
/php-src/ext/mbstring/tests bug43301.phpt
Modified files:
/php-src/ext/mbstring php_mbregex.c
Log:
- Fixed bug #31911 (mb_ereg*_replace() crashes when replacement string
is invalid PHP expression and 'e' option is used)
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/php_mbregex.c?r1=1.59&r2=1.60&diff_format=u
Index: php-src/ext/mbstring/php_mbregex.c
diff -u php-src/ext/mbstring/php_mbregex.c:1.59
php-src/ext/mbstring/php_mbregex.c:1.60
--- php-src/ext/mbstring/php_mbregex.c:1.59 Sun Oct 7 05:15:04 2007
+++ php-src/ext/mbstring/php_mbregex.c Fri Nov 16 12:26:04 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mbregex.c,v 1.59 2007/10/07 05:15:04 davidw Exp $ */
+/* $Id: php_mbregex.c,v 1.60 2007/11/16 12:26:04 jani Exp $ */
#ifdef HAVE_CONFIG_H
@@ -737,7 +737,12 @@
/* null terminate buffer */
smart_str_appendc(&eval_buf, '\0');
/* do eval */
- zend_eval_string(eval_buf.c, &v, description
TSRMLS_CC);
+ if (zend_eval_string(eval_buf.c, &v,
description TSRMLS_CC) == FAILURE) {
+ efree(description);
+ php_error_docref(NULL
TSRMLS_CC,E_ERROR, "Failed evaluating code: %s%s", PHP_EOL, eval_buf.c);
+ /* zend_error() does not return in this
case */
+ }
+
/* result of eval */
convert_to_string(&v);
smart_str_appendl(&out_buf, Z_STRVAL(v),
Z_STRLEN(v));
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/bug43301.phpt?view=markup&rev=1.1
Index: php-src/ext/mbstring/tests/bug43301.phpt
+++ php-src/ext/mbstring/tests/bug43301.phpt
--TEST--
Bug #31911 (mb_ereg*_replace() crashes when replacement string is invalid PHP
expression and 'e' option is used)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
$ptr = 'hello';
$txt = <<<doc
hello, I have got a cr*sh on you
doc;
echo mb_ereg_replace($ptr,'$1',$txt,'e');
?>
--EXPECTF--
Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in
%s/bug43301.php(%d) : mbregex replace on line 1
Fatal error: mb_ereg_replace(): Failed evaluating code:
$1 in %s/bug43301.php on line %d
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php