From 20863db0d26a59ae0fca02c0f53a49f67759f8b6 Mon Sep 17 00:00:00 2001 From: diana Date: Mon, 2 Sep 2024 12:55:15 -0400 Subject: [PATCH] sb-i74 (#325) --- .forge-snapshots/PositionManager_permit.snap | 2 +- .../PositionManager_permit_secondPosition.snap | 2 +- .forge-snapshots/PositionManager_permit_twice.snap | 2 +- src/base/EIP712_v4.sol | 5 +++++ src/libraries/ERC721PermitHash.sol | 14 ++++++++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.forge-snapshots/PositionManager_permit.snap b/.forge-snapshots/PositionManager_permit.snap index e62c334b6..d3f21d676 100644 --- a/.forge-snapshots/PositionManager_permit.snap +++ b/.forge-snapshots/PositionManager_permit.snap @@ -1 +1 @@ -79506 \ No newline at end of file +79595 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_permit_secondPosition.snap b/.forge-snapshots/PositionManager_permit_secondPosition.snap index a0c684a2e..4bd3ebf9a 100644 --- a/.forge-snapshots/PositionManager_permit_secondPosition.snap +++ b/.forge-snapshots/PositionManager_permit_secondPosition.snap @@ -1 +1 @@ -62394 \ No newline at end of file +62483 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_permit_twice.snap b/.forge-snapshots/PositionManager_permit_twice.snap index 2439b1797..39f8dac50 100644 --- a/.forge-snapshots/PositionManager_permit_twice.snap +++ b/.forge-snapshots/PositionManager_permit_twice.snap @@ -1 +1 @@ -45282 \ No newline at end of file +45371 \ No newline at end of file diff --git a/src/base/EIP712_v4.sol b/src/base/EIP712_v4.sol index a17ceee2b..27366668f 100644 --- a/src/base/EIP712_v4.sol +++ b/src/base/EIP712_v4.sol @@ -46,6 +46,11 @@ contract EIP712_v4 is IEIP712_v4 { mstore(add(fmp, 0x02), domainSeparator) mstore(add(fmp, 0x22), dataHash) digest := keccak256(fmp, 0x42) + + // now clean the memory we used + mstore(fmp, 0) // fmp held "\x19\x01", domainSeparator + mstore(add(fmp, 0x20), 0) // fmp+0x20 held domainSeparator, dataHash + mstore(add(fmp, 0x40), 0) // fmp+0x40 held dataHash } } } diff --git a/src/libraries/ERC721PermitHash.sol b/src/libraries/ERC721PermitHash.sol index 4301dbfb0..83fe06f73 100644 --- a/src/libraries/ERC721PermitHash.sol +++ b/src/libraries/ERC721PermitHash.sol @@ -22,6 +22,13 @@ library ERC721PermitHashLibrary { mstore(add(fmp, 0x60), nonce) mstore(add(fmp, 0x80), deadline) digest := keccak256(fmp, 0xa0) + + // now clean the memory we used + mstore(fmp, 0) // fmp held PERMIT_TYPEHASH + mstore(add(fmp, 0x20), 0) // fmp+0x20 held spender + mstore(add(fmp, 0x40), 0) // fmp+0x40 held tokenId + mstore(add(fmp, 0x60), 0) // fmp+0x60 held nonce + mstore(add(fmp, 0x80), 0) // fmp+0x80 held deadline } } @@ -39,6 +46,13 @@ library ERC721PermitHashLibrary { mstore(add(fmp, 0x60), nonce) mstore(add(fmp, 0x80), deadline) digest := keccak256(fmp, 0xa0) + + // now clean the memory we used + mstore(fmp, 0) // fmp held PERMIT_FOR_ALL_TYPEHASH + mstore(add(fmp, 0x20), 0) // fmp+0x20 held operator + mstore(add(fmp, 0x40), 0) // fmp+0x40 held approved + mstore(add(fmp, 0x60), 0) // fmp+0x60 held nonce + mstore(add(fmp, 0x80), 0) // fmp+0x80 held deadline } } }