summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-02-11 12:31:59 +0100
committerStanislav Malyshev <stas@php.net>2019-03-27 23:20:27 -0700
commit0ecac37c40a27ffbd59f34b5920735ee0b7f994c (patch)
tree0f6ec59f5bac6989cb06caaf4eb24c4913751fc4
parent40fe50daf6069f73d0be43d8fcd7d5953053c10d (diff)
downloadphp-git-0ecac37c40a27ffbd59f34b5920735ee0b7f994c.tar.gz
Validate subject encoding in mb_split and mb_ereg_match
We were already validating the subject encoding in most functions, but not these two.
-rw-r--r--ext/mbstring/php_mbregex.c10
-rw-r--r--ext/mbstring/tests/bug77418.phpt7
2 files changed, 12 insertions, 5 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index ab4fe38df2..1b7133c18b 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -1114,6 +1114,11 @@ PHP_FUNCTION(mb_split)
count--;
}
+ if (!php_mb_check_encoding(string, string_len,
+ _php_mb_regex_mbctype2name(MBREX(current_mbctype)))) {
+ RETURN_FALSE;
+ }
+
/* create regex pattern buffer */
if ((re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, MBREX(regex_default_options), MBREX(current_mbctype), MBREX(regex_default_syntax))) == NULL) {
RETURN_FALSE;
@@ -1203,6 +1208,11 @@ PHP_FUNCTION(mb_ereg_match)
}
}
+ if (!php_mb_check_encoding(string, string_len,
+ _php_mb_regex_mbctype2name(MBREX(current_mbctype)))) {
+ RETURN_FALSE;
+ }
+
if ((re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, MBREX(current_mbctype), syntax)) == NULL) {
RETURN_FALSE;
}
diff --git a/ext/mbstring/tests/bug77418.phpt b/ext/mbstring/tests/bug77418.phpt
index b4acc45c21..32577bc98c 100644
--- a/ext/mbstring/tests/bug77418.phpt
+++ b/ext/mbstring/tests/bug77418.phpt
@@ -1,5 +1,5 @@
--TEST--
-Bug #77371 (Heap overflow in utf32be_mbc_to_code)
+Bug #77418 (Heap overflow in utf32be_mbc_to_code)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
@@ -8,7 +8,4 @@ mb_regex_encoding("UTF-32");
var_dump(mb_split("\x00\x00\x00\x5c\x00\x00\x00B","000000000000000000000000000000"));
?>
--EXPECT--
-array(1) {
- [0]=>
- string(30) "000000000000000000000000000000"
-}
+bool(false)