Skip to content

Commit 87ff1fc

Browse files
Treat SETTINGS_INITIAL_WINDOW_SIZE overflow as a connection error (#1131)
Per RFC 9113 section 6.9.2, a change to SETTINGS_INITIAL_WINDOW_SIZE that causes any flow-control window to exceed the maximum size must be treated as a connection error of type FLOW_CONTROL_ERROR. The previous code closed only the affected stream with RST_STREAM, which is a stream error and not compliant with the specification.
1 parent 5a9222e commit 87ff1fc

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎java/org/apache/coyote/http2/Http2UpgradeHandler.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,9 +1970,11 @@ public void setting(Setting setting, long value) throws ConnectionException {
19701970
try {
19711971
stream.incrementWindowSize(diff);
19721972
} catch (Http2Exception h2e) {
1973-
((Stream) stream).close(new StreamException(
1973+
// Per RFC 9113 section 6.9.2, a change to SETTINGS_INITIAL_WINDOW_SIZE that
1974+
// causes any flow-control window to exceed the maximum size is a connection error.
1975+
throw new ConnectionException(
19741976
sm.getString("upgradeHandler.windowSizeTooBig", connectionId, stream.getIdAsString()),
1975-
h2e.getError(), stream.getIdAsInt()));
1977+
Http2Error.FLOW_CONTROL_ERROR);
19761978
}
19771979
}
19781980
} else if (setting == Setting.NO_RFC7540_PRIORITIES) {

‎test/org/apache/coyote/http2/TestHttp2Section_6_9.java‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,10 @@ public void testWindowSizeTooLargeViaSettings() throws Exception {
263263
// Increase the flow control window but keep it under the limit
264264
sendWindowUpdate(3, 1 << 30);
265265

266-
// Now increase beyond the limit via a settings frame
266+
// Now increase beyond the limit via a settings frame.
267+
// Per RFC 9113 section 6.9.2 this must be treated as a connection error
268+
// of type FLOW_CONTROL_ERROR, not a stream error.
267269
sendSettings(0, false, new SettingValue(4, 1 << 30));
268-
// Ack
269-
parser.readFrame();
270-
Assert.assertEquals("3-RST-[" + Http2Error.FLOW_CONTROL_ERROR.getCode() + "]\n", output.getTrace());
271-
270+
handleGoAwayResponse(3, Http2Error.FLOW_CONTROL_ERROR);
272271
}
273272
}

0 commit comments

Comments
 (0)