bug in PHP API, with fix attached

Brad Fitzpatrick brad@danga.com
Wed, 3 Dec 2003 14:10:34 -0800 (PST)


There are two PHP APIs.  It's my understanding that this one is
streams-based and doesn't have the bug you mentioned:


That said, I'll wait for the maintainer of the original PHP client to
accept this patch or let me know if alternate PHP client should be the
de-facto one.

- Brad

On Thu, 4 Dec 2003 tstarling@physics.unimelb.edu.au wrote:

> The PHP API _load_items() function reads in blocks of 1024 bytes. By
> coincidence, I was testing with a message that caused the "\r\nEND\r\n"
> terminator to fall across a 1024 byte boundary. Usually this is no big
> deal, but in my case, the part in the first block was "\r\nEND" and in the
> second block it was just "\r\n". Any empty line is skipped by a continue
> statement without any further processing, leading to another call to
> socket_read() and hence causing the client to block indefinitely.
> The patch is to check if it is near the end, and to read slightly more
> than 1024 bytes if it is.
> Tim Starling
> Wikipedia http://en.wikipedia.org/