fix(BalancerV3Executor): Do data.length check at the beginning of swap
Took 16 minutes
This commit is contained in:
@@ -31,6 +31,9 @@ contract BalancerV3Executor is IExecutor, RestrictTransferFrom, ICallback {
|
||||
payable
|
||||
returns (uint256 calculatedAmount)
|
||||
{
|
||||
if (data.length != 81) {
|
||||
revert BalancerV3Executor__InvalidDataLength();
|
||||
}
|
||||
bytes memory result = VAULT.unlock(
|
||||
abi.encodeCall(
|
||||
BalancerV3Executor.swapCallback,
|
||||
@@ -113,10 +116,6 @@ contract BalancerV3Executor is IExecutor, RestrictTransferFrom, ICallback {
|
||||
address receiver
|
||||
)
|
||||
{
|
||||
if (data.length != 113) {
|
||||
revert BalancerV3Executor__InvalidDataLength();
|
||||
}
|
||||
|
||||
amountGiven = uint256(bytes32(data[0:32]));
|
||||
tokenIn = IERC20(address(bytes20(data[32:52])));
|
||||
tokenOut = IERC20(address(bytes20(data[52:72])));
|
||||
|
||||
@@ -68,7 +68,7 @@ contract BalancerV3ExecutorTest is Constants, TestUtils {
|
||||
assertEq(receiver, BOB);
|
||||
}
|
||||
|
||||
function testDecodeParamsInvalidDataLength() public {
|
||||
function testSwapInvalidDataLength() public {
|
||||
bytes memory invalidParams = abi.encodePacked(
|
||||
osETH_ADDR,
|
||||
waEthWETH_ADDR,
|
||||
@@ -77,7 +77,7 @@ contract BalancerV3ExecutorTest is Constants, TestUtils {
|
||||
);
|
||||
|
||||
vm.expectRevert(BalancerV3Executor__InvalidDataLength.selector);
|
||||
balancerV3Exposed.decodeParams(invalidParams);
|
||||
balancerV3Exposed.swap(1 ether, invalidParams);
|
||||
}
|
||||
|
||||
function testSwap() public {
|
||||
|
||||
Reference in New Issue
Block a user