File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,8 +90,8 @@ contract PreimageOracle is IPreimageOracle {
9090 // len(sig) + len(partOffset) + len(preimage offset) = 4 + 32 + 32 = 0x44
9191 size := calldataload (0x44 )
9292
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 ) )) {
9595 // Store "PartOffsetOOB()"
9696 mstore (0 , 0xfe254987 )
9797 // Revert with "PartOffsetOOB()"
Original file line number Diff line number Diff line change @@ -133,6 +133,16 @@ contract PreimageOracle_Test is Test {
133133 assertTrue (ok);
134134 }
135135
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+
136146 /// @notice Tests that a pre-image cannot be set with an out-of-bounds offset.
137147 function test_loadLocalData_outOfBoundsOffset_reverts () public {
138148 bytes32 preimage = bytes32 (uint256 (0xdeadbeef ));
You can’t perform that action at this time.
0 commit comments