Skip to content

Commit 1afebfb

Browse files
committed
Merge branch 'PHP-5.6' into PHP-7.1
* PHP-5.6: Fix bug #77418 - Heap overflow in utf32be_mbc_to_code [ci skip] Add NEWS Fix more issues with encodilng length Fix #77270: imagecolormatch Out Of Bounds Write on Heap Fix bug #77380 (Global out of bounds read in xmlrpc base64 code) Fix bug #77371 (heap buffer overflow in mb regex functions - compile_string_node) Fix bug #77370 - check that we do not read past buffer end when parsing multibytes Fix #77269: Potential unsigned underflow in gdImageScale Fix bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext) Fix bug #77242 (heap out of bounds read in xmlrpc_decode()) Regenerate certs for openssl tests
2 parents 08bb0ce + 9d6c59e commit 1afebfb

File tree

6 files changed

+22
-2
lines changed

6 files changed

+22
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PHP NEWS
2222
expand_case_fold_string). (Stas)
2323
. Fixed bug #77385 (buffer overflow in fetch_token). (Stas)
2424
. Fixed bug #77394 (Buffer overflow in multibyte case folding - unicode). (Stas)
25+
. Fixed bug #77418 (Heap overflow in utf32be_mbc_to_code). (Stas)
2526

2627
- Phar:
2728
. Fixed bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext). (Stas)

ext/mbstring/oniguruma/enc/utf16_be.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,18 @@ utf16be_is_mbc_newline(const UChar* p, const UChar* end)
7575
}
7676

7777
static 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;

ext/mbstring/oniguruma/enc/utf16_le.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ utf16le_is_mbc_newline(const UChar* p, const UChar* end)
8181
}
8282

8383
static 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];

ext/mbstring/oniguruma/enc/utf32_be.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ utf32be_is_mbc_newline(const UChar* p, const UChar* end)
6060
static OnigCodePoint
6161
utf32be_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

ext/mbstring/oniguruma/enc/utf32_le.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ utf32le_is_mbc_newline(const UChar* p, const UChar* end)
6060
static OnigCodePoint
6161
utf32le_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

ext/mbstring/tests/bug77418.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

0 commit comments

Comments
 (0)