File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -74,8 +74,8 @@ contract PreimageOracle is IPreimageOracle {
74
74
// len(sig) + len(partOffset) + len(preimage offset) = 4 + 32 + 32 = 0x44
75
75
size := calldataload (0x44 )
76
76
77
- // revert if part offset > size+8 (i.e. parts must be within bounds)
78
- if gt ( _partOffset, add (size, 8 )) {
77
+ // revert if part offset >= size+8 (i.e. parts must be within bounds)
78
+ if iszero ( lt ( _partOffset, add (size, 8 ) )) {
79
79
// Store "PartOffsetOOB()"
80
80
mstore (0 , 0xfe254987 )
81
81
// 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