Ruby Forum Ruby-core > Bug in cgi.rb read_multipart

Posted by Timothy Hanson (Guest)
on 30.04.2008 01:18
Attachment: ruby-changes.patch (1,2 KB)
(Received via mailing list)
read_multipart will fail to parse a request when the first part is
exactly 10240 bytes long (including its header, the trailing boundary
and a CRLF).



The problem is that it makes one pass through the main loop (around line
992). It reads the body of the part (around line 1035). Which then sets
buf to "". It then breaks out of the outer loop because buf.size == 0.
It does this even though content_length > 0. It then raises EOFError
since the boundary_end is "".



I have attached a patch for this bug which only breaks the outer loop if
buf.size == 0 && content_length == 0.



Thanks,
Tim