XML-RPC chokes with long server response

clemens.tolboom - June 3, 2008 - 07:40
Project:Drupal
Version:7.x-dev
Component:xml-rpc system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

When receiving long responses from the server (my case 149 kB) preg_replace chokes in replacing the xml header.

Replacing this with a strpos() and substr() replacement I get my data parsed.

patch attached.

AttachmentSizeStatusTest resultOperations
xmlrpc-choke.patch643 bytesIdleFailed: Failed to apply patch.View details | Re-test

#1

clemens.tolboom - June 3, 2008 - 07:58

With chokes I mean it replaces the WHOLE message with an empty string. (Or was my data corrupt? afaik it was not)

My strpos searches for the first occurrence of '?>' while the preg_replace did an eager search for the last fitting '?>'

#2

clemens.tolboom - June 7, 2008 - 15:41

Steps to reproduce.
1. With devel php block insert the following code

xmlrpc();                                // lazy mans include
$message = str_repeat( '<a>a</a>', 128); // 1K string
$message = str_repeat( $message, 80);    // make n K in size
$message = '<e>'. $message .'</e>';      // wrap to make valid xml
$xml_message = xmlrpc_message( '<?xml version="1.0"?>'. $message); // create rpc message
xmlrpc_message_parse( $xml_message);     // and parse
var_dump( $xml_message);                 // check for message value

2. Run the php
3. Note that message part is around 87K in size
4. Now change the 80 into 128
5. See the var_dump message containing a NULL value.

Is this memory dependant?

#3

Gerhard Killesreiter - August 29, 2008 - 12:34
Version:5.7» 7.x-dev

needs to go into D7 first.

#4

Gerhard Killesreiter - August 29, 2008 - 12:35
Status:active» needs work

Does apply to D5 and D6 but needs work for D7.

#5

Damien Tournoud - August 29, 2008 - 12:51

This solution looks a little crude to me. What if there is a "?>" in the message but no XML header?

#6

Damien Tournoud - August 29, 2008 - 13:07
Status:needs work» needs review

Thinking about it, do we really need to strip the <?xml ?> tag.

I also noticed that the parser don't handle correctly the case when $xmlrpc_message->messagetype is not set at the end of the parsing (like in the case of a malformed message like the one above).

AttachmentSizeStatusTest resultOperations
265973-xmlrpc-parse.patch1.1 KBIdleFailed: 7073 passes, 108 fails, 6640 exceptionsView details | Re-test

#7

clemens.tolboom - September 12, 2008 - 12:56

I wrote a test for this in #307477: xmlrpc test for big messages..

To run short I cannot reproduce with memory setting 64M.
Lowering to 32M same.
Lowering to 16M makes the whole testsuite die.

So I guess my test is wrong :(

#8

clemens.tolboom - September 12, 2008 - 15:47

I rewrote the test. And it runs ok.

So my guess is this bug is a 'cannot reproduce' unless my test is wrong.

Patch #6 should be investigated. Although I prefer a test for it first.

#9

clemens.tolboom - September 17, 2008 - 19:37

On third thought ... this is probably PHP version dependent.

My previous PHP version was a Ubuntu 7.04 version on which I reported this issue. I'm not sure how to get this version number :-( On http://packages.ubuntu.com/ choosing Feisty ginve PHP version 5.2.1

My current PHP version is PHP 5.2.4-2ubuntu5.3

So if someone has this older version of PHP he can run the new test #307477: xmlrpc test for big messages..

#10

Anonymous (not verified) - November 11, 2008 - 17:15
Status:needs review» needs work

The last submitted patch failed testing.

#11

Uccio - April 23, 2009 - 11:33
Component:other» base system
Status:needs work» patch (to be ported)

In my case the xmlrpc message is about 500K the php is 5.2.9 and the problem is preg_replace().
I have fix the problem in this way.

AttachmentSizeStatusTest resultOperations
xmlrpc.inc_.patch1.16 KBIgnoredNoneNone

#12

Dave Reid - September 28, 2009 - 02:01
Component:base system» xml-rpc system

Moving to new 'xml-rpc system' component.

#13

Damien Tournoud - October 28, 2009 - 13:28
Status:patch (to be ported)» needs review

#529608: xmlrpc_message_parse() in xmlrpc.inc is not safe for big XML-RPC responses marked as a duplicate.

Here is a reroll of my patch from #6.

AttachmentSizeStatusTest resultOperations
265973-xmlrpc-parse.patch1.24 KBIdlePassed: 14678 passes, 0 fails, 0 exceptionsView details | Re-test
 
 

Drupal is a registered trademark of Dries Buytaert.