Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-humans-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`MerkleProof`: Use custom error to report invalid multiproof instead of reverting with overflow panic.
4 changes: 2 additions & 2 deletions contracts/utils/cryptography/MerkleProof.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ library MerkleProof {
uint256 totalHashes = proofFlags.length;

// Check proof validity.
if (leavesLen + proofLen - 1 != totalHashes) {
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}

Expand Down Expand Up @@ -174,7 +174,7 @@ library MerkleProof {
uint256 totalHashes = proofFlags.length;

// Check proof validity.
if (leavesLen + proofLen - 1 != totalHashes) {
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}

Expand Down