diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java index a34bd3eb79..e69a581a27 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java @@ -303,6 +303,10 @@ final class HpackDecoder { if (headersLength > maxHeaderListSize) { headerListSizeExceeded(streamId, maxHeaderListSize, true); } + + if (state != READ_HEADER_REPRESENTATION) { + throw connectionError(COMPRESSION_ERROR, "Incomplete header block fragment."); + } } /** diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackDecoderTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackDecoderTest.java index 1822033888..1e3db759fa 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackDecoderTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackDecoderTest.java @@ -512,4 +512,17 @@ public class HpackDecoderTest { in.release(); } } + + @Test + public void testIncompleteHeaderFieldRepresentation() throws Http2Exception { + // Incomplete Literal Header Field with Incremental Indexing + byte[] input = {(byte) 0x40}; + ByteBuf in = Unpooled.wrappedBuffer(input); + try { + expectedException.expect(Http2Exception.class); + hpackDecoder.decode(0, in, mockHeaders); + } finally { + in.release(); + } + } } diff --git a/testsuite-http2/pom.xml b/testsuite-http2/pom.xml index df7036673a..499ea0e9c0 100644 --- a/testsuite-http2/pom.xml +++ b/testsuite-http2/pom.xml @@ -67,7 +67,6 @@ 3.8 - Sends a GOAWAY frame 4.2 - Sends a dynamic table size update at the end of header block - 4.3 - Sends invalid header block fragment 5.1 - idle: Sends a DATA frame 5.1 - closed: Sends a DATA frame 5.1 - closed: Sends a HEADERS frame