Skip to content

Use a memory copy to avoid aliasing when RLP encoding short values#6303

Merged
ernestognw merged 3 commits intoOpenZeppelin:masterfrom
Amxx:fix/RLP/avoid-memory-aliasing
Feb 10, 2026
Merged

Use a memory copy to avoid aliasing when RLP encoding short values#6303
ernestognw merged 3 commits intoOpenZeppelin:masterfrom
Amxx:fix/RLP/avoid-memory-aliasing

Conversation

@Amxx
Copy link
Collaborator

@Amxx Amxx commented Jan 21, 2026

No description provided.

@Amxx Amxx added this to the 5.6 milestone Jan 21, 2026
@Amxx Amxx requested a review from ernestognw January 21, 2026 12:16
@Amxx Amxx requested a review from a team as a code owner January 21, 2026 12:16
@changeset-bot
Copy link

changeset-bot bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: 39404fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Walkthrough

The pull request modifies the encode function in the RLP utility contract. Specifically, in the short-path branch that handles single-byte inputs where the byte value is less than SHORT_OFFSET, the function now returns bytes.concat(input) instead of returning input directly. This modification alters the memory allocation behavior for this specific case while maintaining the same logical output. The long-path execution remains unchanged, and no function signatures were modified.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning No description was provided by the author, making it impossible to assess whether it relates to the changeset. Add a pull request description explaining the purpose of the memory copy change and why it prevents aliasing issues in RLP encoding.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: using memory copy (via bytes.concat) to avoid memory aliasing in RLP encoding for short values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it needs a changelog entry, does it?

@ernestognw ernestognw merged commit c2e62b4 into OpenZeppelin:master Feb 10, 2026
21 checks passed
Amxx added a commit that referenced this pull request Feb 10, 2026
…6303)

Co-authored-by: Ernesto <ernestognw@Ernestos-MacBook-Pro.local>
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
@Amxx Amxx deleted the fix/RLP/avoid-memory-aliasing branch February 10, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants