Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

Check for Zero Address in `changeHost`.

Summary:

The changeHost function does not check if _newHost is the zero address, which could lead to an invalid host.

Recommended Mitigation:

Update the changeHost function by implementing:

  1. Either require statement checking for a zero address.

    function changeHost(address _newHost) external onlyHost {
    require(_newHost != address(0), "Invalid address");
    if(!participant[_newHost]) {
    revert OnlyParticipantsCanBeHost();
    }
    host = _newHost;
    emit NewHost(host);
    }
  2. Or, an ifstatement along with a custom error of ZeroAddress.

// ... rest of code ...
error ZeroAddress();
// ... rest of code ...
function changeHost(address _newHost) external onlyHost {
if(_newHost != address(0)){
revert ZeroAddress();
};
if(!participant[_newHost]) {
revert OnlyParticipantsCanBeHost();
}
host = _newHost;
emit NewHost(host);
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.