[ 
https://issues.apache.org/jira/browse/WW-5874?focusedWorklogId=1056825&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1056825
 ]

ASF GitHub Bot logged work on WW-5874:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Nov/26 10:07
            Start Date: 24/Nov/26 10:07
    Worklog Time Spent: 10m 
      Work Description: shadowe1ite opened a new pull request, #2161:
URL: https://github.com/apache/struts/pull/2161

   Fixes [WW-5874](https://issues.apache.org/jira/browse/WW-5874)
   
   `JakartaStreamMultiPartRequest` read every form field fully into a 
`ByteArrayOutputStream` and built the whole `String` before checking 
`maxStringLength`. So with `maxStringLength=10`, a 100 KB field was still 
buffered in full.
   
   The field is now decoded as it's read and only up to `maxStringLength` 
characters are kept. The rest of the part is still read so the error can report 
the real length, but it isn't buffered. The limit is still counted in 
characters, so multibyte input behaves the same as before.
   
   `exceedsMaxStringLength(String, long)` is added to 
`AbstractMultiPartRequest`, and the existing `String` overload calls it, so 
subclasses aren't affected.
   
   Tests cover a 100,000 character field with a limit of 10, multibyte input, 
and an end to end `parse()` check that the field is dropped and the error 
reports the real length. They fail without the fix; all multipart and upload 
tests in core pass with it.
   




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1056825)
    Remaining Estimate: 0h
            Time Spent: 10m

> struts.multipart.maxStringLength does not bound memory used for multipart 
> form fields
> -------------------------------------------------------------------------------------
>
>                 Key: WW-5874
>                 URL: https://issues.apache.org/jira/browse/WW-5874
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 7.5.0
>            Reporter: ALAN S
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {\{JakartaStreamMultiPartRequest}} reads each form field fully into memory 
> and builds the whole \{{String}} before checking 
> \{{struts.multipart.maxStringLength}}. The limit rejects the value but does 
> not bound the memory used to read it.
> The field should be decoded as it is read, keeping at most 
> \{{maxStringLength}} characters.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to