Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,9 @@ private void consumeHeaderFrame(final RawFrame frame, final H2Stream stream) thr
}
final ByteBuffer payload = frame.getPayloadContent();
if (frame.isFlagSet(FrameFlag.PRIORITY)) {
if (payload == null || payload.remaining() < 5) {
throw new H2ConnectionException(H2Error.FRAME_SIZE_ERROR, "Invalid HEADERS priority payload");
}
payload.getInt();
payload.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1863,4 +1863,30 @@ void testWindowUpdateZeroIncrementOnStreamIsStreamError() throws Exception {
Assertions.assertEquals(H2Error.PROTOCOL_ERROR, H2Error.getByCode(((H2StreamResetException) cause).getCode()));
}

@Test
void testHeadersWithPriorityFlagAndShortPayloadRejected() throws Exception {
final AbstractH2StreamMultiplexer mux = new H2StreamMultiplexerImpl(
protocolIOSession,
FRAME_FACTORY,
StreamIdGenerator.ODD,
httpProcessor,
CharCodingConfig.DEFAULT,
H2Config.custom().build(),
h2StreamListener,
() -> streamHandler);

final RawFrame headers = new RawFrame(
FrameType.HEADERS.getValue(),
FrameFlag.PRIORITY.getValue() | FrameFlag.END_HEADERS.getValue(),
2,
ByteBuffer.allocate(0));

final H2ConnectionException ex = Assertions.assertThrows(
H2ConnectionException.class,
() -> mux.onInput(ByteBuffer.wrap(encodeFrame(headers))));

Assertions.assertEquals(H2Error.FRAME_SIZE_ERROR, H2Error.getByCode(ex.getCode()));
}


}
Loading