Skip to content

Commit ba3d195

Browse files
smalyshevcmb69
authored andcommitted
Fix bug #77242 (heap out of bounds read in xmlrpc_decode())
(cherry picked from commit 4fc0bce)
1 parent 4371c1a commit ba3d195

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ PHP NEWS
6464
- SQLite3:
6565
. Fixed bug #77051 (Issue with re-binding on SQLite3). (BohwaZ)
6666

67+
- Xmlrpc:
68+
. Fixed bug #77242 (heap out of bounds read in xmlrpc_decode()). (cmb)
69+
6770
06 Dec 2018, PHP 7.3.0
6871

6972
- Core:

ext/xmlrpc/libxmlrpc/xml_element.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ xml_element* xml_elem_parse_buf(const char* in_buf, int len, XML_ELEM_INPUT_OPTI
720720
long byte_idx = XML_GetCurrentByteIndex(parser);
721721
/* int byte_total = XML_GetCurrentByteCount(parser); */
722722
const char * error_str = XML_ErrorString(err_code);
723+
if(byte_idx > len) {
724+
byte_idx = len;
725+
}
723726
if(byte_idx >= 0) {
724727
snprintf(buf,
725728
sizeof(buf),

ext/xmlrpc/tests/bug77242.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #77242 (heap out of bounds read in xmlrpc_decode())
3+
--SKIPIF--
4+
<?php if (!extension_loaded("xmlrpc")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
var_dump(xmlrpc_decode(base64_decode("PD94bWwgdmVyc2lvbmVuY29kaW5nPSJJU084ODU5NyKkpKSkpKSkpKSkpKSkpKSkpKSkpKSk")));
8+
?>
9+
--EXPECT--
10+
NULL

0 commit comments

Comments
 (0)