Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10886 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] ActionController read_multipart faults if boundary at exactly 10240 bytes

Reported by: mspeight Assigned to: core
Priority: normal Milestone: 2.0.3
Component: ActionPack Version: edge
Severity: normal Keywords: verified, patch, multipart
Cc:

Description

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.

Attachments

multipart-boundary-issue.diff (12.0 kB) - added by ariejan on 03/27/08 15:29:35.

Change History

01/21/08 23:48:38 changed by bitsweat

  • keywords set to multipart.
  • milestone changed from 2.x to 2.0.3.

Good catch. Needs a unit test + patch.

03/27/08 11:24:48 changed by ariejan

  • owner changed from core to ariejan.
  • status changed from new to assigned.

I've written the unit test + patch.

See #11440 and give it a +1 if it works for you.

03/27/08 15:29:02 changed by ariejan

  • summary changed from ActionController read_multipart faults if boundary at exactly 10240 bytes to [PATCH] ActionController read_multipart faults if boundary at exactly 10240 bytes.

03/27/08 15:29:35 changed by ariejan

  • attachment multipart-boundary-issue.diff added.

03/27/08 15:30:37 changed by ariejan

Added patch and unit tests from #11440.

03/28/08 08:18:19 changed by harm_kabisa

+1 works for me!

03/28/08 09:53:50 changed by ralphd

Finally this is solved. +1 works for me!

03/28/08 09:58:47 changed by micheldegraaf

Nice work! +1

03/28/08 09:59:56 changed by ariejan

  • summary changed from [PATCH] ActionController read_multipart faults if boundary at exactly 10240 bytes to [PATCH] [VERIFIED] ActionController read_multipart faults if boundary at exactly 10240 bytes.

03/28/08 10:01:25 changed by ariejan

  • keywords changed from multipart to verified, patch, multipart.
  • summary changed from [PATCH] [VERIFIED] ActionController read_multipart faults if boundary at exactly 10240 bytes to [PATCH] ActionController read_multipart faults if boundary at exactly 10240 bytes.

03/28/08 10:15:56 changed by ariejan

  • owner changed from ariejan to core.
  • status changed from assigned to new.

03/28/08 19:55:35 changed by david

  • status changed from new to closed.
  • resolution set to fixed.

(In [9113]) Fixed that ActionController::Base#read_multipart would fail if boundary was exactly 10240 bytes (closes #10886) [ariejan]

03/28/08 22:24:28 changed by ariejan

  • status changed from closed to reopened.
  • resolution deleted.

[9113] changes the unit tests and code. However, the supplied 'boundary_problem_file' used in the unit test was not added, which makes the unit test fail.

The attached file should be added as actionpack/test/fixtures/multipart/boundary_problem_file

03/28/08 22:25:21 changed by ariejan

  • status changed from reopened to closed.
  • resolution set to fixed.

Sorry, the file has been added in [9117]