Resolve off-by-one errors in settings bounds. (#97)

Motivation:

When we're validating that settings are in their bounds, we should probably endeavour to
express those bounds correctly.

Modifications:

- Fixed the bounds checks on SETTINGS_INITIAL_WINDOW_SIZE and SETTINGS_MAX_FRAME_SIZE.
- Added regression tests.

Result:

Better correctness.
This commit is contained in:
Cory Benfield authored and Johannes Weiss committed 2019-04-15 12:06:10 +01:00
1 parent ae57c2a0d8
commit 08db9d8cd4
3 files changed
+24 -2

No files matched your search

@@ -1304,11 +1304,11 @@ extension HTTP2ConnectionStateMachine {
return .connectionError(underlyingError: NIOHTTP2Errors.InvalidSetting(setting: setting), type: .protocolError)
}
case .initialWindowSize:
guard setting._value < HTTP2FlowControlWindow.maxSize else {
guard setting._value <= HTTP2FlowControlWindow.maxSize else {
return .connectionError(underlyingError: NIOHTTP2Errors.InvalidSetting(setting: setting), type: .flowControlError)
}
case .maxFrameSize:
guard setting._value >= (1 << 14) && setting._value < ((1 << 24) - 1) else {
guard setting._value >= (1 << 14) && setting._value <= ((1 << 24) - 1) else {
return .connectionError(underlyingError: NIOHTTP2Errors.InvalidSetting(setting: setting), type: .protocolError)
}
default: