fix: [C4-109-L02] Unlink could be called for any unlinked handles by passing zero

This commit is contained in:
vicnaum
2023-09-04 17:30:40 +01:00
parent c659b77b72
commit 154e3e992d
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);
}