GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reject invalid content-length in PUSH_PROMISE with a stream error (#1… · netty/netty@a143321

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-http2/src
    • main/java/io/netty/handler/codec/http2
      • DefaultHttp2ConnectionDecoder.java
    • test/java/io/netty/handler/codec/http2
      • DefaultHttp2ConnectionDecoderTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoder.java‎

Copy file name to clipboardExpand all lines: codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoder.java
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,14 @@ public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promi
669669
// extract the content-length header
670670
List<? extends CharSequence> contentLength = headers.getAll(HttpHeaderNames.CONTENT_LENGTH);
671671
if (contentLength != null && !contentLength.isEmpty()) {
672-
long cLength = HttpUtil.normalizeAndGetContentLength(contentLength, false, true);
672+
long cLength;
673+
try {
674+
cLength = HttpUtil.normalizeAndGetContentLength(contentLength, false, true);
675+
} catch (IllegalArgumentException e) {
676+
throw streamError(promisedStreamId, PROTOCOL_ERROR, e,
677+
"Promised request on stream %d for promised stream %d contains invalid content-length header",
678+
streamId, promisedStreamId);
679+
}
673680
if (cLength != -1 && cLength != 0) {
674681
throw streamError(promisedStreamId, PROTOCOL_ERROR,
675682
"Promised request on stream %d for promised stream %d contains invalid content-length header",
Collapse file

‎codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoderTest.java‎

Copy file name to clipboardExpand all lines: codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoderTest.java
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,24 @@ public void testPromiseWithContentLengthOfZero() throws Exception {
964964
verify(listener).onPushPromiseRead(eq(ctx), eq(STREAM_ID), eq(PUSH_STREAM_ID), eq(headers), eq(0));
965965
}
966966

967+
@ParameterizedTest
968+
@ValueSource(strings = {"abc", "1,2", "99999999999999999999"})
969+
public void testPromiseWithInvalidContentLength(String contentLength) throws Exception {
970+
final Http2FrameListener dec = decode();
971+
final Http2Headers headers = new DefaultHttp2Headers(false)
972+
.method("GET").scheme("https").authority("example.org").path("/")
973+
.set(HttpHeaderNames.CONTENT_LENGTH, contentLength);
974+
Http2Exception ex = assertThrows(Http2Exception.class, new Executable() {
975+
@Override
976+
public void execute() throws Throwable {
977+
dec.onPushPromiseRead(ctx, STREAM_ID, PUSH_STREAM_ID, headers, 0);
978+
}
979+
});
980+
assertEquals(PROTOCOL_ERROR, ex.error());
981+
assertEquals(PUSH_STREAM_ID, Http2Exception.streamId(ex));
982+
verify(listener, never()).onPushPromiseRead(eq(ctx), anyInt(), anyInt(), any(Http2Headers.class), anyInt());
983+
}
984+
967985
@Test
968986
public void priorityReadAfterGoAwaySentShouldAllowFramesForStreamCreatedByLocalEndpoint() throws Exception {
969987
mockGoAwaySentShouldAllowFramesForStreamCreatedByLocalEndpoint();

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.