Avoid overflow on empty multiproof (#4564)
This commit is contained in:
5
.changeset/large-humans-remain.md
Normal file
5
.changeset/large-humans-remain.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'openzeppelin-solidity': patch
|
||||
---
|
||||
|
||||
`MerkleProof`: Use custom error to report invalid multiproof instead of reverting with overflow panic.
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user