Skip to content

fix: remove padded_len() u8 overflow in DATA frame padding release#914

Merged
seanmonstar merged 1 commit into
masterfrom
sean/qqtktozuqyzx
Jun 12, 2026
Merged

fix: remove padded_len() u8 overflow in DATA frame padding release#914
seanmonstar merged 1 commit into
masterfrom
sean/qqtktozuqyzx

Conversation

@seanmonstar

Copy link
Copy Markdown
Member

padded_len() returned Option and computed pad_len + 1 to account for the pad length field byte. When pad_len=255 (the maximum per RFC 7540 Section 6.1), 255u8 + 1 overflows to 0, causing the auto-release in recv_data() to release 0 bytes instead of 256. This leaks 256 bytes of flow control capacity per frame for both the stream and connection windows.

Remove padded_len() entirely (it had a single call site) and compute padding overhead inline as flow_controlled_len() - payload().len(), which does not rely on details of the payload construction at all, making it more robust, and uses usize arithmetic and cannot overflow.

(Just required formatting to merge from previous PR)

Closes #908

padded_len() returned Option<u8> and computed pad_len + 1 to account
for the pad length field byte. When pad_len=255 (the maximum per RFC
7540 Section 6.1), 255u8 + 1 overflows to 0, causing the auto-release
in recv_data() to release 0 bytes instead of 256. This leaks 256 bytes
of flow control capacity per frame for both the stream and connection
windows.

Remove padded_len() entirely (it had a single call site) and compute
padding overhead inline as flow_controlled_len() - payload().len(),
which does not rely on details of the payload construction at all,
making it more robust, and uses usize arithmetic and cannot overflow.
@seanmonstar seanmonstar merged commit 9231cb0 into master Jun 12, 2026
6 checks passed
@seanmonstar seanmonstar deleted the sean/qqtktozuqyzx branch June 12, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant