From: Christoph M. Becker Date: Thu, 12 Mar 2020 12:04:04 +0000 (+0100) Subject: Fix #79371: mb_strtolower (UTF-32LE): stack-buffer-overflow X-Git-Tag: php-7.3.17RC1~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fdffd1c55d771ca22ae217784ab75fce592ad38;p=php Fix #79371: mb_strtolower (UTF-32LE): stack-buffer-overflow We make sure that negative values are properly compared. --- diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c index ac452b6a20..acb16bf06e 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-- + +--FILE-- + +--EXPECT-- +string(8) "3f000000"