Skip to content

Commit b8048de

Browse files
committed
Fix #79371: mb_strtolower (UTF-32LE): stack-buffer-overflow
We make sure that negative values are properly compared. (cherry picked from commit 1fdffd1)
1 parent c099c71 commit b8048de

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ PHP NEWS
3030
. Fixed bug #79282 (Use-of-uninitialized-value in exif). (CVE-2020-7064)
3131
(Nikita)
3232

33+
- MBstring:
34+
. Fixed bug #79371 (mb_strtolower (UTF-32LE): stack-buffer-overflow at
35+
php_unicode_tolower_full). (CVE-2020-7065) (cmb)
36+
3337
- MySQLi:
3438
. Fixed bug #64032 (mysqli reports different client_version). (cmb)
3539

ext/mbstring/php_unicode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static int convert_case_filter(int c, void *void_data)
315315

316316
/* Handle invalid characters early, as we assign special meaning to
317317
* codepoints above 0xffffff. */
318-
if (UNEXPECTED(c > 0xffffff)) {
318+
if (UNEXPECTED((unsigned) c > 0xffffff)) {
319319
(*data->next_filter->filter_function)(c, data->next_filter);
320320
return 0;
321321
}

ext/mbstring/tests/bug79371.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #79371 (mb_strtolower (UTF-32LE): stack-buffer-overflow)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$bytes = array(0xef, 0xbf, 0xbd, 0xef);
10+
$str = implode(array_map("chr", $bytes));
11+
var_dump(bin2hex(mb_strtolower($str, "UTF-32LE")));
12+
?>
13+
--EXPECT--
14+
string(8) "3f000000"

0 commit comments

Comments
 (0)