diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-03-12 13:04:04 +0100 |
---|---|---|
committer | Derick Rethans <github@derickrethans.nl> | 2020-03-17 09:46:41 +0000 |
commit | 69155120e68d2e614d5c300974a1a5610cfa2e8b (patch) | |
tree | 149a03bdb07b1706d69c624e9d6d8b3982369ca5 | |
parent | e2b5f18896ca4169859c8ca058a9926aad6e3763 (diff) | |
download | php-git-69155120e68d2e614d5c300974a1a5610cfa2e8b.tar.gz |
Fix #79371: mb_strtolower (UTF-32LE): stack-buffer-overflow
We make sure that negative values are properly compared.
-rw-r--r-- | ext/mbstring/php_unicode.c | 2 | ||||
-rw-r--r-- | ext/mbstring/tests/bug79371.phpt | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c index 664f760fc3..4fa650d894 100644 --- a/ext/mbstring/php_unicode.c +++ b/ext/mbstring/php_unicode.c @@ -315,7 +315,7 @@ static int convert_case_filter(int c, void *void_data) /* Handle invalid characters early, as we assign special meaning to * codepoints above 0xffffff. */ - if (UNEXPECTED(c > 0xffffff)) { + if (UNEXPECTED((unsigned) c > 0xffffff)) { (*data->next_filter->filter_function)(c, data->next_filter); return 0; } diff --git a/ext/mbstring/tests/bug79371.phpt b/ext/mbstring/tests/bug79371.phpt new file mode 100644 index 0000000000..3014feba53 --- /dev/null +++ b/ext/mbstring/tests/bug79371.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #79371 (mb_strtolower (UTF-32LE): stack-buffer-overflow) +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring extension not available'); +?> +--FILE-- +<?php +$bytes = array(0xef, 0xbf, 0xbd, 0xef); +$str = implode(array_map("chr", $bytes)); +var_dump(bin2hex(mb_strtolower($str, "UTF-32LE"))); +?> +--EXPECT-- +string(8) "3f000000" |