Skip to content

Commit

Permalink
Add bounds check to keccak function
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Jan 11, 2025
1 parent 7879d9b commit 16f39f9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/LibBytes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.15;

library LibBytes {
function keccak(bytes memory data, uint256 offset, uint256 length) internal pure returns (bytes32 result) {
require(offset + length <= data.length, "index out of bounds");
assembly {
result := keccak256(add(data, add(32, offset)), length)
}
Expand Down

0 comments on commit 16f39f9

Please sign in to comment.