arturobernalg opened a new pull request, #1266: URL: https://github.com/apache/tomcat/pull/1266
https://bz.apache.org/bugzilla/show_bug.cgi?id=70366 On each DATA frame, `Stream.receivedData()` looks up `content-length` in the request headers on the connection thread, while the container thread may already be modifying the same `MimeHeaders` (`RemoteIpValve` removes and restores `X-Forwarded-For`). The lookup can return the next header's value, which resets a valid request with PROTOCOL_ERROR, or miss the header, which disables the RFC 9113, section 8.1.1 check. The content length is now resolved in `receivedEndOfHeaders()`, before the stream is passed to a container thread, and that value is used while the body is received. As a side effect, an invalid or duplicate content-length is rejected at the end of the headers instead of on the first DATA frame. Testing: - New `TestStream.testContentLengthIndependentOfHeaderChanges`: a valve removes the header and the client sends 256 bytes for a declared 128. On main the request is accepted (200); with the fix the stream is reset with PROTOCOL_ERROR. - Local Tomcat built from main, h2c with `RemoteIpValve`, 32 concurrent POSTs with `X-Forwarded-For`: 2 of 10 five-second runs were reset with `NumberFormatException: For input string: "Java-http-client/27"` (the User-Agent value). With the fix, 0 of 20. - All `org.apache.coyote.http2` tests pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
