You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/protocol/http2/continuation_frame.rb
+18-3Lines changed: 18 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,9 @@ module Protocol
9
9
moduleHTTP2
10
10
# Module for frames that can be continued with CONTINUATION frames.
11
11
moduleContinued
12
+
# @constant [Integer] The maximum number of continuation frames to read to prevent resource exhaustion.
13
+
LIMIT=8
14
+
12
15
# Initialize a continuable frame.
13
16
# @parameter arguments [Array] Arguments passed to parent constructor.
14
17
definitialize(*)
@@ -30,12 +33,20 @@ def end_headers?
30
33
end
31
34
32
35
# Read the frame and any continuation frames from the stream.
36
+
#
37
+
# There is an upper limit to the number of continuation frames that can be read to prevent resource exhaustion. If the limit is 0, only one frame will be read (the initial frame). Otherwise, the limit decrements with each continuation frame read.
38
+
#
33
39
# @parameter stream [IO] The stream to read from.
34
40
# @parameter maximum_frame_size [Integer] Maximum allowed frame size.
35
-
defread(stream,maximum_frame_size)
36
-
super
41
+
# @parameter limit [Integer] The maximum number of continuation frames to read.
42
+
defread(stream,maximum_frame_size,limit=LIMIT)
43
+
super(stream,maximum_frame_size)
37
44
38
45
unlessend_headers?
46
+
iflimit.zero?
47
+
raiseProtocolError,"Too many continuation frames!"
Copy file name to clipboardExpand all lines: releases.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Releases
2
2
3
+
## Unreleased
4
+
5
+
- Introduce a limit to the number of CONTINUATION frames that can be read to prevent resource exhaustion. The default limit is 8 continuation frames, which means a total of 9 frames (1 initial + 8 continuation). This limit can be adjusted by passing a different value to the `limit` parameter in the `Continued.read` method. Setting the limit to 0 will only read the initial frame without any continuation frames. In order to change the default, you can redefine the `LIMIT` constant in the `Protocol::HTTP2::Continued` module, OR you can pass a different frame class to the framer.
6
+
3
7
## v0.22.0
4
8
5
9
### Added Priority Update Frame and Stream Priority
0 commit comments