Add memo size check#1868
Conversation
|
User petrosyan.levon93@gmail.com does not have a PR Review subscription. Go to Team management and add this email to the PR Review subscription. |
Summary by CodeRabbit
Walkthrough
ChangesMemo decoding validation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2972c16cbc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Check that the memo length is valid | ||
| unsigned char memo_length = r.padded_memo[0]; | ||
| if (memo_length > this->params->get_memo_bytes()) { | ||
| if (memo_length > this->params->get_memo_bytes() || memo_length > (r.padded_memo.size() - 1)) { |
There was a problem hiding this comment.
Guard empty memo buffers before subtracting
This new bounds check still misses a decrypted recipient payload whose serialized padded_memo is empty: r.padded_memo[0] has already read out of bounds, and r.padded_memo.size() - 1 wraps to a huge value, so the intended Unable to identify coin path is not reached. A sender can craft an authenticated payload with trailing bytes to satisfy the fixed outer ciphertext size while leaving the inner memo string empty, so wallet scanning can still hit undefined behavior instead of rejecting the coin; check empty() before indexing/subtracting in both identify paths.
Useful? React with 👍 / 👎.
|
User petrosyan.levon93@gmail.com does not have a PR Review subscription. Go to Team management and add this email to the PR Review subscription. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/libspark/coin.cpp (1)
4-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winApply the repository’s C++ formatting rules to the new helper.
The anonymous namespace uses same-line braces, and the helper is tab-indented. Use a newline before the namespace brace and four spaces throughout this added block.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/libspark/coin.cpp` around lines 4 - 25, Reformat the DecodeMemoOrThrow helper block to match repository C++ style: place the anonymous namespace opening brace on the following line and replace tab indentation with four spaces throughout the added namespace and helper code. Preserve all logic unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/libspark/coin.cpp`:
- Around line 4-25: Reformat the DecodeMemoOrThrow helper block to match
repository C++ style: place the anonymous namespace opening brace on the
following line and replace tab indentation with four spaces throughout the added
namespace and helper code. Preserve all logic unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cf3ad6a8-3d73-4b41-94d5-601821ef5724
📒 Files selected for processing (1)
src/libspark/coin.cpp
No description provided.