mirror of
https://github.com/php/php-src.git
synced 2024-11-28 04:14:26 +08:00
- Fixed possible crash in mb_ereg_search_init() using empty pattern
This commit is contained in:
parent
3781026cb8
commit
18768584e2
@ -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);
|
||||
|
18
ext/mbstring/tests/empty_pattern.phpt
Normal file
18
ext/mbstring/tests/empty_pattern.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user