-
Notifications
You must be signed in to change notification settings - Fork 2
fix: use correct read uvarint function when decoding Handshake covenants #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Aurora Gaffney <aurora@blinklabs.io>
📝 WalkthroughWalkthroughThe Decode method in Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/handshake/covenant.go (1)
46-56: Consider bounds-checkingitemCountanditemLengthto avoid huge allocationsBecause
ReadUvarintReadercan return arbitrarily largeuint64values from untrusted input,for range itemCountandmake([]byte, itemLength)could be abused to force very large loops/allocations. If this code runs on untrusted network data, consider enforcing protocol-level limits onitemCountanditemLength(e.g., max items per covenant, max item size) and returning an error when exceeded.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/handshake/covenant.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/handshake/covenant.go (1)
internal/handshake/varint.go (1)
ReadUvarintReader(29-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
internal/handshake/covenant.go (1)
42-52: Correct helper used for Handshake varint decodingSwitching both
itemCountanditemLengthtoReadUvarintReader(r)aligns covenant decoding with the custom Handshake varint format implemented ininternal/handshake/varint.goand avoids relying on the reader implementingio.Reader+io.ByteReader. Error propagation and control flow remain unchanged, so this looks like a safe and targeted correctness fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
Summary by cubic
Fixed Handshake covenant decoding by using ReadUvarintReader for varints instead of binary.ReadUvarint with a ByteReader cast. Prevents panics on non-ByteReader inputs and correctly parses item counts and lengths.
Written for commit 53830a8. Summary will update automatically on new commits.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.