Skip to content

Commit 4fc0bce

Browse files
committed
Fix bug #77242 (heap out of bounds read in xmlrpc_decode())
1 parent f510625 commit 4fc0bce

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ext/xmlrpc/libxmlrpc/xml_element.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,9 @@ xml_element* xml_elem_parse_buf(const char* in_buf, int len, XML_ELEM_INPUT_OPTI
723723
long byte_idx = XML_GetCurrentByteIndex(parser);
724724
/* int byte_total = XML_GetCurrentByteCount(parser); */
725725
const char * error_str = XML_ErrorString(err_code);
726+
if(byte_idx > len) {
727+
byte_idx = len;
728+
}
726729
if(byte_idx >= 0) {
727730
snprintf(buf,
728731
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)