From 39540354b1463c9476032840a1ae2014d2c37bc4 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Tue, 1 Oct 2024 22:58:49 +0100 Subject: [PATCH] (nameRegistry): check short name is not zero --- src/errors/Errors.sol | 2 ++ src/names/NameRegistry.sol | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/errors/Errors.sol b/src/errors/Errors.sol index 155d4d0..c4ac305 100644 --- a/src/errors/Errors.sol +++ b/src/errors/Errors.sol @@ -95,4 +95,6 @@ interface INameRegistryErrors { error CirclesNamesAvatarAlreadyHasCustomNameOrSymbol(address avatar, string nameOrSymbol, uint8 code); error CirclesNamesOrganizationHasNoSymbol(address organization, uint8 code); + + error CirclesNamesShortNameZero(address avatar, uint256 nonce); } diff --git a/src/names/NameRegistry.sol b/src/names/NameRegistry.sol index fff400a..890f313 100644 --- a/src/names/NameRegistry.sol +++ b/src/names/NameRegistry.sol @@ -292,6 +292,11 @@ contract NameRegistry is Base58Converter, INameRegistry, INameRegistryErrors, IC } function _storeShortName(address _avatar, uint72 _shortName, uint256 _nonce) internal { + if (_shortName == uint72(0)) { + // short name cannot be zero (but congrats if you got it!) + // this would break the reverse lookup + revert CirclesNamesShortNameZero(_avatar, _nonce); + } // assign the name to the address shortNames[_avatar] = _shortName; // assign the address to the name