com php-src: Fix bug #78069 - Out-of-bounds read in iconv.c:_php_iconv_mime_decode() due to i nteger overflow: NEWS ext/iconv/iconv.c ext/iconv/t
ests/bug78069.data ext/iconv/tests/bug780 69.phpt
| From: | Christoph Michael Becker | Date: | Tue, 28 May 2019 07:01:00 +0000 |
| Subject: | com php-src: Fix bug #78069 - Out-of-bounds read in iconv.c:_php_iconv_mime_decode() due to i nteger overflow: NEWS ext/iconv/iconv.c ext/iconv/t ests/bug78069.data ext/iconv/tests/bug780 69.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106370@lists.php.net to get a copy of this message | ||
Commit: 70523ce41ff400ea00343a03f297332cb1f1b77b
Author: Stanislav Malyshev <stas@php.net> Mon, 27 May 2019 16:32:42 -0700
Committer: Christoph M. Becker <cmbecker69@gmx.de> Tue, 28 May 2019 09:01:00 +0200
Parents: 903b1828dcd68f7cf8b9177a3fe6f481bf627ba9
Branches: PHP-7.3.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=70523ce41ff400ea00343a03f297332cb1f1b77b
Log:
Fix bug #78069 - Out-of-bounds read in iconv.c:_php_iconv_mime_decode() due to integer overflow
(cherry picked from commit 7cf7148a8f8f4f55fb04de2a517d740bb6253eac)
Bugs:
https://bugs.php.net/78069
Changed paths:
M NEWS
M ext/iconv/iconv.c
A ext/iconv/tests/bug78069.data
A ext/iconv/tests/bug78069.phpt
Diff:
diff --git a/NEWS b/NEWS
index 79e0386..db237e6 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,10 @@ PHP NEWS
. Fixed bug #77973 (Uninitialized read in gdImageCreateFromXbm).
(CVE-2019-11038) (cmb)
+- Iconv:
+ . Fixed bug #78069 (Out-of-bounds read in iconv.c:_php_iconv_mime_decode()
+ due to integer overflow). (CVE-2019-11039). (maris dot adam)
+
- JSON:
. Fixed bug #77843 (Use after free with json serializer). (Nikita)
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index d80bac7..24aefcb 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -1663,7 +1663,9 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char
*st
* we can do at this point. */
if (*(p1 + 1) == '=') {
++p1;
- --str_left;
+ if (str_left > 1) {
+ --str_left;
+ }
}
err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl);
diff --git a/ext/iconv/tests/bug78069.data b/ext/iconv/tests/bug78069.data
new file mode 100644
index 0000000..ebd5d0b
Binary files /dev/null and b/ext/iconv/tests/bug78069.data differ
diff --git a/ext/iconv/tests/bug78069.phpt b/ext/iconv/tests/bug78069.phpt
new file mode 100644
index 0000000..1341a5e
--- /dev/null
+++ b/ext/iconv/tests/bug78069.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #78069 (Out-of-bounds read in iconv.c:_php_iconv_mime_decode() due to integer overflow)
+--SKIPIF--
+<?php
+if (!extension_loaded('iconv')) die('skip ext/iconv required');
+?>
+--FILE--
+<?php
+$hdr = iconv_mime_decode_headers(file_get_contents(__DIR__ . "/bug78069.data"),2);
+var_dump(count($hdr));
+?>
+DONE
+--EXPECT--
+int(1)
+DONE
\ No newline at end of file