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

`getActivePlayerIndex` return wrong value

Summary

function getActivePlayerIndex(address player) external view returns (uint256) return wrong value

Vulnerability Details

function getActivePlayerIndex(address player) external view returns (uint256) return 0 for not active player can
be duplicated with the player at index 0

Impact

The first player in the array players is always not active due to the return 0 value

Tools Used

manual
foundry

Recommendations

Instead of returning 0 for not active player this function should return int256 value
For example: return -1 if the player is not active

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

Lead Judging Commences

Hamiltonite Lead Judge about 2 years 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.

Give us feedback!