File tree Expand file tree Collapse file tree 6 files changed +25
-5
lines changed
Expand file tree Collapse file tree 6 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -3,19 +3,20 @@ PHP NEWS
33?? ??? 2018, PHP 5.6.40
44
55- GD:
6- . Fixed bug #77269 (efree() on uninitialized Heap data in imagescale leads to
6+ . Fixed bug #77269 (efree() on uninitialized Heap data in imagescale leads to
77 use-after-free). (cmb)
88 . Fixed bug #77270 (imagecolormatch Out Of Bounds Write on Heap). (cmb)
99
1010- Mbstring:
1111 . Fixed bug #77370 (Buffer overflow on mb regex functions - fetch_token). (Stas)
12- . Fixed bug #77371 (heap buffer overflow in mb regex functions
12+ . Fixed bug #77371 (heap buffer overflow in mb regex functions
1313 - compile_string_node). (Stas)
1414 . Fixed bug #77381 (heap buffer overflow in multibyte match_at). (Stas)
15- . Fixed bug #77382 (heap buffer overflow due to incorrect length in
15+ . Fixed bug #77382 (heap buffer overflow due to incorrect length in
1616 expand_case_fold_string). (Stas)
1717 . Fixed bug #77385 (buffer overflow in fetch_token). (Stas)
1818 . Fixed bug #77394 (Buffer overflow in multibyte case folding - unicode). (Stas)
19+ . Fixed bug #77418 (Heap overflow in utf32be_mbc_to_code). (Stas)
1920
2021- Phar:
2122 . Fixed bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext). (Stas)
Original file line number Diff line number Diff line change @@ -75,16 +75,18 @@ utf16be_is_mbc_newline(const UChar* p, const UChar* end)
7575}
7676
7777static OnigCodePoint
78- utf16be_mbc_to_code (const UChar * p , const UChar * end ARG_UNUSED )
78+ utf16be_mbc_to_code (const UChar * p , const UChar * end )
7979{
8080 OnigCodePoint code ;
8181
8282 if (UTF16_IS_SURROGATE_FIRST (* p )) {
83+ if (end - p < 4 ) return 0 ;
8384 code = ((((p [0 ] - 0xd8 ) << 2 ) + ((p [1 ] & 0xc0 ) >> 6 ) + 1 ) << 16 )
8485 + ((((p [1 ] & 0x3f ) << 2 ) + (p [2 ] - 0xdc )) << 8 )
8586 + p [3 ];
8687 }
8788 else {
89+ if (end - p < 2 ) return 0 ;
8890 code = p [0 ] * 256 + p [1 ];
8991 }
9092 return code ;
Original file line number Diff line number Diff line change @@ -81,13 +81,14 @@ utf16le_is_mbc_newline(const UChar* p, const UChar* end)
8181}
8282
8383static OnigCodePoint
84- utf16le_mbc_to_code (const UChar * p , const UChar * end ARG_UNUSED )
84+ utf16le_mbc_to_code (const UChar * p , const UChar * end )
8585{
8686 OnigCodePoint code ;
8787 UChar c0 = * p ;
8888 UChar c1 = * (p + 1 );
8989
9090 if (UTF16_IS_SURROGATE_FIRST (c1 )) {
91+ if (end - p < 4 ) return 0 ;
9192 code = ((((c1 - 0xd8 ) << 2 ) + ((c0 & 0xc0 ) >> 6 ) + 1 ) << 16 )
9293 + ((((c0 & 0x3f ) << 2 ) + (p [3 ] - 0xdc )) << 8 )
9394 + p [2 ];
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ utf32be_is_mbc_newline(const UChar* p, const UChar* end)
6060static OnigCodePoint
6161utf32be_mbc_to_code (const UChar * p , const UChar * end ARG_UNUSED )
6262{
63+ if (end - p < 4 ) return 0 ;
6364 return (OnigCodePoint )(((p [0 ] * 256 + p [1 ]) * 256 + p [2 ]) * 256 + p [3 ]);
6465}
6566
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ utf32le_is_mbc_newline(const UChar* p, const UChar* end)
6060static OnigCodePoint
6161utf32le_mbc_to_code (const UChar * p , const UChar * end ARG_UNUSED )
6262{
63+ if (end - p < 4 ) return 0 ;
6364 return (OnigCodePoint )(((p [3 ] * 256 + p [2 ]) * 256 + p [1 ]) * 256 + p [0 ]);
6465}
6566
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug #77371 (Heap overflow in utf32be_mbc_to_code)
3+ --SKIPIF--
4+ <?php extension_loaded ('mbstring ' ) or die ('skip mbstring not available ' ); ?>
5+ --FILE--
6+ <?php
7+ mb_regex_encoding ("UTF-32 " );
8+ var_dump (mb_split ("\x00\x00\x00\x5c\x00\x00\x00B " ,"000000000000000000000000000000 " ));
9+ ?>
10+ --EXPECT--
11+ array(1) {
12+ [0]=>
13+ string(30) "000000000000000000000000000000"
14+ }
You can’t perform that action at this time.
0 commit comments