fix: compress only len check#2233
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis change adds a runtime validation check in token transfer processing to ensure compression indices referenced in CompressedOnly TLVs remain within the actual count of compressions provided, preventing out-of-bounds access by returning a specific error when violated. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@programs/compressed-token/program/src/compressed_token/transfer2/token_inputs.rs`:
- Around line 60-65: The current check correctly guards against out-of-bounds
compression_index by computing compressions_len from inputs.compressions and
returning TokenError::CompressionIndexOutOfBounds when idx >= compressions_len;
hoist the computation of compressions_len = inputs.compressions.as_ref().map(|c|
c.len()).unwrap_or(0) out of the loop that processes TLVs (so it’s computed once
before iterating) and then use that precomputed compressions_len together with
the existing check on compression_index to maintain the defensive validation.
Summary by CodeRabbit
Release Notes