File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -90,8 +90,8 @@ contract PreimageOracle is IPreimageOracle {
90
90
// len(sig) + len(partOffset) + len(preimage offset) = 4 + 32 + 32 = 0x44
91
91
size := calldataload (0x44 )
92
92
93
- // revert if part offset > size+8 (i.e. parts must be within bounds)
94
- if gt ( _partOffset, add (size, 8 )) {
93
+ // revert if part offset >= size+8 (i.e. parts must be within bounds)
94
+ if iszero ( lt ( _partOffset, add (size, 8 ) )) {
95
95
// Store "PartOffsetOOB()"
96
96
mstore (0 , 0xfe254987 )
97
97
// Revert with "PartOffsetOOB()"
Original file line number Diff line number Diff line change @@ -133,6 +133,16 @@ contract PreimageOracle_Test is Test {
133
133
assertTrue (ok);
134
134
}
135
135
136
+ /// @notice Tests that adding a global keccak256 pre-image at the part boundary reverts.
137
+ function test_loadKeccak256PreimagePart_partBoundary_reverts () public {
138
+ bytes memory preimage = hex "deadbeef " ;
139
+ uint256 offset = preimage.length + 8 ;
140
+
141
+ // TODO: remove magic errors
142
+ vm.expectRevert (0xfe254987 );
143
+ oracle.loadKeccak256PreimagePart (offset, preimage);
144
+ }
145
+
136
146
/// @notice Tests that a pre-image cannot be set with an out-of-bounds offset.
137
147
function test_loadLocalData_outOfBoundsOffset_reverts () public {
138
148
bytes32 preimage = bytes32 (uint256 (0xdeadbeef ));
You can’t perform that action at this time.
0 commit comments