Skip to content

Commit 1cc2182

Browse files
committed
Fix bug #77380 (Global out of bounds read in xmlrpc base64 code)
1 parent 28362ed commit 1cc2182

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

ext/xmlrpc/libxmlrpc/base64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void base64_encode_xmlrpc(struct buffer_st *b, const char *source, int length)
7777

7878
while (!hiteof) {
7979
unsigned char igroup[3], ogroup[4];
80-
int c, n;
80+
int c, n;
8181

8282
igroup[0] = igroup[1] = igroup[2] = 0;
8383
for (n = 0; n < 3; n++) {
@@ -169,7 +169,7 @@ void base64_decode_xmlrpc(struct buffer_st *bfr, const char *source, int length)
169169
return;
170170
}
171171

172-
if (dtable[c] & 0x80) {
172+
if (dtable[(unsigned char)c] & 0x80) {
173173
/*
174174
fprintf(stderr, "Offset %i length %i\n", offset, length);
175175
fprintf(stderr, "character '%c:%x:%c' in input file.\n", c, c, dtable[c]);

ext/xmlrpc/tests/bug77380.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #77380 (Global out of bounds read in xmlrpc base64 code)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("xmlrpc")) print "skip";
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(xmlrpc_decode(base64_decode("PGJhc2U2ND7CkzwvYmFzZTY0Pgo=")));
10+
?>
11+
--EXPECT--
12+
object(stdClass)#1 (2) {
13+
["scalar"]=>
14+
string(0) ""
15+
["xmlrpc_type"]=>
16+
string(6) "base64"
17+
}

0 commit comments

Comments
 (0)