GeezerVison is showing github.com — Fix HTTP 2 PUSH_PROMISE stream association validation (#16952) · netty/netty@6dabf56
File tree
Expand file treeCollapse file tree
Open diff view settings
main/java/io/netty/handler/codec/http2 test/java/io/netty/handler/codec/http2
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2FrameReader.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -343,6 +343,7 @@ private void verifySettingsFrame() throws Http2Exception { |
343 | 343 | } |
344 | 344 |
|
345 | 345 | private void verifyPushPromiseFrame() throws Http2Exception { |
| 346 | + verifyAssociatedWithAStream(); |
346 | 347 | verifyNotProcessingHeaders(); |
347 | 348 |
|
348 | 349 | // Subtract the length of the promised stream ID field, to determine the length of the |
|
Collapse file
Copy file name to clipboardExpand all lines: codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2FrameReaderTest.java +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -340,6 +340,27 @@ public void execute() throws Throwable { |
340 | 340 | } |
341 | 341 | } |
342 | 342 |
|
| 343 | + @Test |
| 344 | + public void failedWhenPushPromiseFrameNotAssociateWithStream() throws Http2Exception { |
| 345 | + final ByteBuf input = Unpooled.buffer(); |
| 346 | + try { |
| 347 | + writeFrameHeader(input, INT_FIELD_LENGTH, PUSH_PROMISE, new Http2Flags().endOfHeaders(true), 0); |
| 348 | + input.writeInt(2); |
| 349 | + Http2Exception ex = assertThrows(Http2Exception.class, new Executable() { |
| 350 | + @Override |
| 351 | + public void execute() throws Throwable { |
| 352 | + frameReader.readFrame(ctx, input, listener); |
| 353 | + } |
| 354 | + }); |
| 355 | + assertFalse(ex instanceof Http2Exception.StreamException); |
| 356 | + assertEquals(Http2Error.PROTOCOL_ERROR, ex.error()); |
| 357 | + verify(listener, never()).onPushPromiseRead(any(ChannelHandlerContext.class), anyInt(), anyInt(), |
| 358 | + any(Http2Headers.class), anyInt()); |
| 359 | + } finally { |
| 360 | + input.release(); |
| 361 | + } |
| 362 | + } |
| 363 | + |
343 | 364 | @Test |
344 | 365 | public void readPriorityFrame() throws Http2Exception { |
345 | 366 | ByteBuf input = Unpooled.buffer(); |
|