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

getActivePlayerIndex returns valid index if player not found

Summary

The function getActivePlayerIndex loops through array and returns 0 if players has not been found. This is ambiguous since 0 is a valid index for array in Solidity.

Vulnerability Details

Function returns 0, which is a valid array index.

Impact

Misleading return value

Recommendations

Either:

  • Return -1 as int256

  • Return uint256 max value and make it explicit to the consumer of the contract

  • Revert with error

Updates

Lead Judging Commences

Hamiltonite Lead Judge almost 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.