Skip to content

Commit

Permalink
Fix bug #77380 (Global out of bounds read in xmlrpc base64 code)
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev committed Jan 6, 2019
1 parent c6e34d9 commit 4feb9e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/xmlrpc/libxmlrpc/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void base64_encode_xmlrpc(struct buffer_st *b, const char *source, int length)

while (!hiteof) {
unsigned char igroup[3], ogroup[4];
int c, n;
int c, n;

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

if (dtable[c] & 0x80) {
if (dtable[(unsigned char)c] & 0x80) {
/*
fprintf(stderr, "Offset %i length %i\n", offset, length);
fprintf(stderr, "character '%c:%x:%c' in input file.\n", c, c, dtable[c]);
Expand Down
17 changes: 17 additions & 0 deletions ext/xmlrpc/tests/bug77380.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Bug #77380 (Global out of bounds read in xmlrpc base64 code)
--SKIPIF--
<?php
if (!extension_loaded("xmlrpc")) print "skip";
?>
--FILE--
<?php
var_dump(xmlrpc_decode(base64_decode("PGJhc2U2ND7CkzwvYmFzZTY0Pgo=")));
?>
--EXPECT--
object(stdClass)#1 (2) {
["scalar"]=>
string(0) ""
["xmlrpc_type"]=>
string(6) "base64"
}

0 comments on commit 4feb9e6

Please sign in to comment.