ActionController read_multipart faults with "bad boundary end of body part"
if you have a large post and the content has a boundary at 10240 bytes.
Steps to duplicate
(a) A multi-part post greater tran 10240 bytes.
(b) The post content has a boundary (plus trailing CR+LF) ending at exactly 10240
bytes
Example content.
-----------------------------boundary[CR][LF]
Content-Disposition: form-data; name="tran[id]"[CR][LF]
25031[CR][LF]
-----------------------------boundary[CR][LF]
etc ....
-----------------------------boundary[CR][LF]
# *** BOUNDARY **** ^ BOUNDARY HERE
Content-Disposition: form-data; name="tran[id]"[CR][LF]
25031[CR][LF]
-----------------------------boundary--
What Happens
(a) buff is filled to 10240 bytes and ends in "--boundary[CR][LF]"
(b) params are extracted as normal
(c) BUT, When the last param within buf is extracted, The length of buf becomes zero.
(d) the following test "break if buf.size == 0" results in "bad boundary end of body part" begin raised
Solution
(a) Remove the break if buf.size == 0, Since a buf size of 0 is valid,
Also the read of zero (0) bytes is already trapped prior.