Skip to content

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

Open
mehrdada wants to merge 1 commit into
hyperium:masterfrom
mehrdada:fix/padded-len-overflow
Open

fix: remove padded_len() u8 overflow in DATA frame padding release#908
mehrdada wants to merge 1 commit into
hyperium:masterfrom
mehrdada:fix/padded-len-overflow

Conversation

@mehrdada
Copy link
Copy Markdown

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.

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.
@mehrdada mehrdada force-pushed the fix/padded-len-overflow branch from 0a21c75 to 6804533 Compare May 17, 2026 05:58
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