- Fixed possible crash in mb_ereg_search_init() using empty pattern

This commit is contained in:
Felipe Pena 2011-11-21 19:15:18 +00:00
parent 3781026cb8
commit 18768584e2
2 changed files with 25 additions and 2 deletions

View File

@ -1310,14 +1310,19 @@ PHP_FUNCTION(mb_ereg_search_init)
{
size_t argc = ZEND_NUM_ARGS();
zval *arg_str;
char *arg_pattern, *arg_options;
int arg_pattern_len, arg_options_len;
char *arg_pattern = NULL, *arg_options = NULL;
int arg_pattern_len = 0, arg_options_len = 0;
OnigSyntaxType *syntax = NULL;
OnigOptionType option;
if (zend_parse_parameters(argc TSRMLS_CC, "z|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
return;
}
if (arg_pattern_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty pattern");
RETURN_FALSE;
}
option = MBREX(regex_default_options);
syntax = MBREX(regex_default_syntax);

View File

@ -0,0 +1,18 @@
--TEST--
Check for empty pattern
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
mb_ereg_search_init("","","");
mb_split("","");
mb_ereg_search_regs();
?>
--EXPECTF--
Warning: mb_ereg_search_init(): Empty pattern in %s on line %d
Warning: mb_split(): Empty regular expression in %s on line %d
Warning: mb_ereg_search_regs(): No regex given in %s on line %d