From 8c5fc11869aab91ede609f7f76d8cbd1af90e072 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 25 Jul 2026 09:05:57 +1200 Subject: [PATCH] Mask GOAWAY last stream id --- lib/protocol/http2/goaway_frame.rb | 1 + releases.md | 4 ++++ test/protocol/http2/goaway_frame.rb | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/lib/protocol/http2/goaway_frame.rb b/lib/protocol/http2/goaway_frame.rb index 0402beb..c316acc 100644 --- a/lib/protocol/http2/goaway_frame.rb +++ b/lib/protocol/http2/goaway_frame.rb @@ -33,6 +33,7 @@ def unpack data = super last_stream_id, error_code = data.unpack(FORMAT) + last_stream_id &= 0x7fffffff return last_stream_id, error_code, data.slice(8, data.bytesize-8) end diff --git a/releases.md b/releases.md index 20e4a35..9cccd4e 100644 --- a/releases.md +++ b/releases.md @@ -1,5 +1,9 @@ # Releases +## Unreleased + + - Ignore the reserved high bit when decoding GOAWAY last stream IDs. + ## v0.26.1 - Improve `StreamError` messages for HTTP/2 stream reset error codes. diff --git a/test/protocol/http2/goaway_frame.rb b/test/protocol/http2/goaway_frame.rb index b968e1f..e1454ca 100644 --- a/test/protocol/http2/goaway_frame.rb +++ b/test/protocol/http2/goaway_frame.rb @@ -38,5 +38,11 @@ def before expect(frame.unpack).to be == [3, 2, data] end + + it "ignores the reserved high bit of the last stream id" do + frame.pack 0x80000003, 2, data + + expect(frame.unpack).to be == [3, 2, data] + end end end