Merge pull request #123 from lens-protocol/fix/C4-109-L02-passing-zero-to-unlink

fix: [C4-109-L02] Unlink could be called for any unlinked handles by passing zero
This commit is contained in:
Alan
2023-09-04 18:35:06 +01:00
committed by GitHub
2 changed files with 6 additions and 3 deletions

View File

@@ -176,6 +176,9 @@ contract TokenHandleRegistry is ITokenHandleRegistry {
}
function _unlink(uint256 handleId, uint256 profileId, address transactionExecutor) private {
if (handleId == 0 || profileId == 0) {
revert RegistryErrors.DoesNotExist();
}
if (
ILensHandles(LENS_HANDLES).exists(handleId) &&
ILensHandles(LENS_HANDLES).ownerOf(handleId) != transactionExecutor &&

View File

@@ -112,16 +112,16 @@ contract TokenHandleRegistryTest is BaseTest {
assertEq(tokenHandleRegistry.resolve(handleId), profileId);
assertEq(tokenHandleRegistry.getDefaultHandle(profileId), handleId);
vm.expectRevert(RegistryErrors.NotLinked.selector);
vm.expectRevert(RegistryErrors.DoesNotExist.selector);
vm.prank(otherAddress);
tokenHandleRegistry.unlink(handleId, 0);
vm.expectRevert(RegistryErrors.NotLinked.selector);
vm.expectRevert(RegistryErrors.DoesNotExist.selector);
vm.prank(otherAddress);
tokenHandleRegistry.unlink(0, profileId);
console.log('0, 0');
vm.expectRevert(RegistryErrors.NotLinked.selector);
vm.expectRevert(RegistryErrors.DoesNotExist.selector);
vm.prank(otherAddress);
tokenHandleRegistry.unlink(0, 0);
}