Created
July 21, 2018 19:58
-
-
Save vasa-develop/82c2de027242c909064d65d69395d72b to your computer and use it in GitHub Desktop.
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Locked Name Registrar | |
contract NameRegistrar { | |
bool public unlocked = false; // registrar locked, no name updates | |
struct NameRecord { // map hashes to addresses | |
bytes32 name; | |
address mappedAddress; | |
} | |
mapping(address => NameRecord) public registeredNameRecord; // records who registered names | |
mapping(bytes32 => address) public resolve; // resolves hashes to addresses | |
function register(bytes32 _name, address _mappedAddress) public { | |
// set up the new NameRecord | |
NameRecord newRecord; | |
newRecord.name = _name; | |
newRecord.mappedAddress = _mappedAddress; | |
resolve[_name] = _mappedAddress; | |
registeredNameRecord[msg.sender] = newRecord; | |
require(unlocked); // only allow registrations if contract is unlocked | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment