Issue Details (XML | Word | Printable)

Key: FILEUPLOAD-108
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Jochen Wiedmann
Reporter: Amichai Rothman
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons FileUpload

FileUploadBase.parseHeaders() has logic and performance flaws related to max header size.

Created: 19/May/06 06:39 AM   Updated: 09/Mar/07 08:32 PM
Return to search
Component/s: None
Affects Version/s: 1.1 Final
Fix Version/s: 1.2

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works commons-fileupload-1.1-bug-108.patch 2006-05-19 06:46 AM Amichai Rothman 2 kB

Resolution Date: 04/Aug/06 09:23 PM


 Description  « Hide
FileUploadBase.parseHeaders() has logic and performance flaws:

MultipartStream.readHeaders() already limits the total header size, so FileUploadBase.parseHeaders() doesn't have to limit each header as well (it can cause problems, and gains nothing).

Furthermore, the current implementation would cause an ArrayOutOfBoundsException if a longer header would in fact be present, which is undocumented and would cause trouble in calling app.

Finally, the local buffer which is the cause of this limit is not needed - copying into it just takes up more memory and cpu.

A simple solution is using substrings rather than a buffer - substrings point into the same char buffer as the original (immutable) string, so no additional memory is used, no char copying is necessary, the undocumented exception will not occur, and the artificial max header size is no longer needed, so FileUpload can be more robust and flexible.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Amichai Rothman added a comment - 19/May/06 06:46 AM
An implementation of the suggested fix.

Jochen Wiedmann added a comment - 04/Aug/06 09:23 PM
Applied, thank you!