Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

it might be safer if return -1 if player if not in the array

Summary

function getActivePlayerIndex return 0 if address hasn't been found in the player address list.
However, it's not safe if players[0] has been occupied with an address.
maybe try returning -1 instead.

Vulnerability Details

Impact

Tools Used

Recommendations

function getActivePlayerIndex(address player) external view returns (int256) {
for (uint256 i = 0; i < players.length; i++) {
if (players[i] == player) {
return i;
}
}
return -1;
}

Updates

Lead Judging Commences

Hamiltonite Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

getActivePlayerIndex can say a player is both entered at slot 0 and inactive

Support

FAQs

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