Skip to content
Open
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 @@ -266,6 +266,9 @@ class Http2Reader(
when (id) {
// SETTINGS_HEADER_TABLE_SIZE
1 -> {
if (value < 0) {
throw IOException("PROTOCOL_ERROR SETTINGS_HEADER_TABLE_SIZE > 2^31 - 1")
}
}

// SETTINGS_ENABLE_PUSH
Expand Down
16 changes: 16 additions & 0 deletions okhttp/src/jvmTest/kotlin/okhttp3/internal/http2/Http2Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ class Http2Test {
)
}

@Test fun readSettingsFrameNegativeHeaderTableSize() {
writeMedium(frame, 6) // 2 for the code and 4 for the value
frame.writeByte(Http2.TYPE_SETTINGS)
frame.writeByte(FLAG_NONE)
frame.writeInt(0) // Settings are always on the connection stream 0.
frame.writeShort(1) // SETTINGS_HEADER_TABLE_SIZE
frame.writeInt(Int.MIN_VALUE)
assertFailsWith<IOException> {
reader.nextFrame(requireSettings = false, BaseTestHandler())
}.also { expected ->
assertThat(expected.message).isEqualTo(
"PROTOCOL_ERROR SETTINGS_HEADER_TABLE_SIZE > 2^31 - 1",
)
}
}

@Test fun readSettingsFrameNegativeWindowSize() {
writeMedium(frame, 6) // 2 for the code and 4 for the value
frame.writeByte(Http2.TYPE_SETTINGS)
Expand Down
Loading