File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ Release History
1111**Bugfixes **
1212
1313- Fixed padding parsing for ``PushPromiseFrame ``.
14+ - Fixed unchecked frame length for ``PriorityFrame ``. It now correctly raises ``InvalidFrameError ``.
1415
1516**Other Changes **
1617
Original file line number Diff line number Diff line change @@ -323,8 +323,14 @@ def serialize_body(self):
323323 return self .serialize_priority_data ()
324324
325325 def parse_body (self , data ):
326+ if len (data ) > 5 :
327+ raise InvalidFrameError (
328+ "PRIORITY must have 5 byte body: actual length %s." %
329+ len (data )
330+ )
331+
326332 self .parse_priority_data (data )
327- self .body_len = len ( data )
333+ self .body_len = 5
328334
329335
330336class RstStreamFrame (Frame ):
Original file line number Diff line number Diff line change @@ -262,6 +262,12 @@ def test_priority_frame_with_all_data_parses_properly(self):
262262 assert f .exclusive is True
263263 assert f .body_len == 5
264264
265+ def test_priority_frame_invalid (self ):
266+ with pytest .raises (ValueError ):
267+ decode_frame (
268+ b'\x00 \x00 \x06 \x02 \x00 \x00 \x00 \x00 \x01 \x80 \x00 \x00 \x04 \x40 \xFF '
269+ )
270+
265271 def test_priority_frame_comes_on_a_stream (self ):
266272 with pytest .raises (ValueError ):
267273 PriorityFrame (0 )
You can’t perform that action at this time.
0 commit comments