Fix file uploads > 2 GiB in formpost middleware

Formpost middleware fails to upload files larger then 2 GiB due to
an Overflow error. The reason is that the readline() will use a
readline(int(content_length)) later on and fail if it is larger than
2GiB.  Since it is not required to read the whole content into memory
to detect the boundary only read the amount of required bytes.

The underlying error is located in Python 2.7 and is related to
cStringIO: http://bugs.python.org/issue7358

Closes-Bug: #1326429
Change-Id: I196edda647921c2691d278cebd1cca80ebd360f2
This commit is contained in:
Christian Schwede 2014-06-04 15:27:48 +00:00
parent c384d76c57
commit 7056ec6a16
1 changed files with 1 additions and 1 deletions

View File

@ -242,7 +242,7 @@ def _iter_requests(wsgi_input, boundary):
:returns: A generator of file-like objects for each part.
"""
boundary = '--' + boundary
if wsgi_input.readline().strip() != boundary:
if wsgi_input.readline(len(boundary + '\r\n')).strip() != boundary:
raise FormInvalid('invalid starting boundary')
boundary = '\r\n' + boundary
input_buffer = ''