Bug 66236 - maxSavePostSize=-1 crashes ssl renegotiation
Summary: maxSavePostSize=-1 crashes ssl renegotiation
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 10
Classification: Unclassified
Component: Authentication (show other bugs)
Version: 10.0.22
Hardware: All Linux
: P2 normal (vote)
Target Milestone: ------
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-24 12:53 UTC by bernd.stoltefuss
Modified: 2022-09-01 06:29 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bernd.stoltefuss 2022-08-24 12:53:43 UTC
According to documentation maxSavePostSize=-1 means "disable limit".
This was working fine in previous versions.

With tomcat 10 this will trigger an exception when a ssl rehandshake is necessary:
 java.lang.IllegalArgumentException: capacity < 0: (-1 < 0)
  at java.base/java.nio.Buffer.createCapacityException(Buffer.java:279)
  at java.base/java.nio.ByteBuffer.allocate(ByteBuffer.java:362)
  at org.apache.coyote.http11.filters.BufferedInputFilter.setLimit(BufferedInputFilter.java:69)
  at org.apache.coyote.http11.Http11Processor.sslReHandShake(Http11Processor.java:1285)

Reason seems to be, that line 1285 of Http11Processor allocates a buffer with the size of maxSavePostSize without checking for the special meanings of 0 and -1.
Comment 1 Mark Thomas 2022-08-25 16:41:48 UTC
A code inspection suggests that this hasn't been working in previous versions.

While the special values of 0 and -1 work for FORM auth and HTTP upgrade, they do not work for TLS renegotiation.

The different buffers in use (ByteBuffer for TLS, ByteChunk for FORM and upgrade) mean that implementing the special values for TLS without creating huge buffers for every connection will be non-trivial.
Comment 2 Mark Thomas 2022-08-25 19:06:40 UTC
It looks like reverting to using ByteChunk to store the request body in BufferedInputFilter should fix this. Initial impressions are that this works but I want to run more tests before committing.
Comment 3 Mark Thomas 2022-09-01 06:29:01 UTC
Fixed in:
- 10.1.x for 10.1.0-M18 onwards
- 10.0.x for 10.0.24 onwards
-  9.0.x for  9.0.66 onwards
-  8.5.x for  8.5.83 onwards