From 53e7a69556ee64dcb72ecddc3fe2726244af3739 Mon Sep 17 00:00:00 2001 From: poma Date: Mon, 22 Mar 2021 20:16:14 +0300 Subject: [PATCH] fix CVF-21 --- contracts/TornadoTrees.sol | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/contracts/TornadoTrees.sol b/contracts/TornadoTrees.sol index c491153..d550513 100644 --- a/contracts/TornadoTrees.sol +++ b/contracts/TornadoTrees.sol @@ -149,9 +149,10 @@ contract TornadoTrees is Initializable { bytes32 deposit = offset + i >= depositsV1Length ? deposits[offset + i] : tornadoTreesV1.deposits(offset + i); require(leafHash == deposit, "Incorrect deposit"); assembly { - mstore(add(add(data, mul(ITEM_SIZE, i)), 0x7c), blockNumber) - mstore(add(add(data, mul(ITEM_SIZE, i)), 0x78), instance) - mstore(add(add(data, mul(ITEM_SIZE, i)), 0x64), hash) + let itemOffset := add(data, mul(ITEM_SIZE, i)) + mstore(add(itemOffset, 0x7c), blockNumber) + mstore(add(itemOffset, 0x78), instance) + mstore(add(itemOffset, 0x64), hash) } if (offset + i >= depositsV1Length) { delete deposits[offset + i]; @@ -200,9 +201,10 @@ contract TornadoTrees is Initializable { bytes32 withdrawal = offset + i >= withdrawalsV1Length ? withdrawals[offset + i] : tornadoTreesV1.withdrawals(offset + i); require(leafHash == withdrawal, "Incorrect withdrawal"); assembly { - mstore(add(add(data, mul(ITEM_SIZE, i)), 0x7c), blockNumber) - mstore(add(add(data, mul(ITEM_SIZE, i)), 0x78), instance) - mstore(add(add(data, mul(ITEM_SIZE, i)), 0x64), hash) + let itemOffset := add(data, mul(ITEM_SIZE, i)) + mstore(add(itemOffset, 0x7c), blockNumber) + mstore(add(itemOffset, 0x78), instance) + mstore(add(itemOffset, 0x64), hash) } if (offset + i >= withdrawalsV1Length) { delete withdrawals[offset + i];