This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 810f49d5ff6d64b704af85d5b8d0aab9ec3c83f5 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Jan 25 12:13:55 2024 +0000 Report HTTP/2 header parsing errors earlier --- java/org/apache/coyote/http2/Http2Parser.java | 11 ++++++----- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2Parser.java b/java/org/apache/coyote/http2/Http2Parser.java index 10b86a2bc8..ec26909761 100644 --- a/java/org/apache/coyote/http2/Http2Parser.java +++ b/java/org/apache/coyote/http2/Http2Parser.java @@ -266,6 +266,9 @@ class Http2Parser { swallowPayload(streamId, FrameType.HEADERS.getId(), padLength, true, buffer); + // Validate the headers so far + hpackDecoder.getHeaderEmitter().validateHeaders(); + if (Flags.isEndOfHeaders(flags)) { onHeadersComplete(streamId); } else { @@ -429,6 +432,9 @@ class Http2Parser { readHeaderPayload(streamId, payloadSize, buffer); + // Validate the headers so far + hpackDecoder.getHeaderEmitter().validateHeaders(); + if (endOfHeaders) { headersCurrentStream = -1; onHeadersComplete(streamId); @@ -620,11 +626,6 @@ class Http2Parser { Http2Error.COMPRESSION_ERROR); } - // Delay validation (and triggering any exception) until this point - // since all the headers still have to be read if a StreamException is - // going to be thrown. - hpackDecoder.getHeaderEmitter().validateHeaders(); - synchronized (output) { output.headersEnd(streamId, headersEndStream); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 446d2d7ea9..aa9d561731 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -182,6 +182,11 @@ <code>Content-Type</code> value to improve performance by reducing repeated <code>byte[]</code> to <code>String</code> conversions. (markt) </fix> + <fix> + Improve error reporting to HTTP/2 clients for header processing errors + by reporting problems at the end of the frame where the error was + detected rather than at the end of the headers. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org