Fix(RLP): reject trailing bytes in scalar/data decoders#6519
Fix(RLP): reject trailing bytes in scalar/data decoders#6519BhariGowda wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: f9c7e94 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR fixes a correctness bug in the RLP decoder library where scalar decoders ( 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
<## Motivation
Fixes #6515
RLP scalar decoders (
decodeUint256,decodeBytes,decodeBytes32,decodeBool,decodeAddress,decodeString) silently ignored trailingbytes after a valid RLP data item.
For example:
decodeUint256(0x0102)returned1instead of revertingdecodeBytes(0x83646f6780)returneddoginstead of revertingdecodeListalready correctly rejected trailing bytes — this fixbrings scalar decoders in line with the same behavior.
Changes
Added trailing bytes check to
readUint256andreadBytes:readUint256: requireitemOffset + itemLength == item.length()readBytes: requireoffset + length == item.length()readBytes32,decodeBool,decodeAddress,decodeStringalldelegate to these two functions so are fixed automatically.
Testing
Added 3 regression tests. All 20 tests pass.