fix snappy frame multi chunks and refactor#521
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes snappy frame handling to properly support multi-chunk frames and refactors the validation logic for improved precision and security.
Changes:
- Implemented multi-chunk snappy frame parsing with proper accumulation of uncompressed lengths across chunks
- Replaced heuristic frame size validation with precise calculation using
snap::raw::max_compress_len - Added defense-in-depth validation by checking decompressed length matches declared length on the Zig side
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| rust/libp2p-glue/src/req_resp/varint.rs | Refactored calculate_snappy_frame_size to handle multi-chunk frames, added max_framed_len helper, improved validation with overflow checks |
| rust/libp2p-glue/src/req_resp/outbound_protocol.rs | Updated calls to calculate_snappy_frame_size with new parameter, removed heuristic validation |
| rust/libp2p-glue/src/req_resp/inbound_protocol.rs | Updated calls to calculate_snappy_frame_size with new parameter, removed heuristic validation |
| pkgs/network/src/ethlibp2p.zig | Enhanced frame parsing to return declared length, added validation that decompressed length matches declared length |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 2 commits
January 26, 2026 11:27
Signed-off-by: grapebaba <grapebaba@grapebabadeMacBook-Pro.local>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
g11tech
approved these changes
Jan 26, 2026
Member
g11tech
left a comment
There was a problem hiding this comment.
seems already tested against ream interop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
length.