The constructor does not validate the length of the players
and rewards
arrays passed as input. These arrays are critical to the reward distribution logic, and any mismatch in their lengths can lead to serious issues such as out-of-bounds errors or incorrect mapping of rewards to players. Without this validation, the contract can be deployed in an inconsistent state, where some players might not receive rewards, or rewards might be incorrectly assigned.
Failure to validate the lengths of the players
and rewards
arrays could result in the following:
Inconsistent State: If the lengths differ, some players may not receive rewards, or the rewards might not be accurately assigned.
Potential for Out-of-Bounds Errors: Accessing an index in the rewards
array that does not exist could result in out-of-bounds errors during deployment or execution.
Unintended Behavior: The contract may not function as intended, leading to mistrust from users and potential financial losses.
Deploy the contract with mismatched players
and rewards
arrays:
Observe that the contract is deployed without any errors, despite the mismatch in array lengths.
When trying to access the reward for the second player, the reward might be incorrect or might not be set at all.
Implement a check in the constructor to ensure that the lengths of the players
and rewards
arrays match before proceeding with the rest of the logic. This ensures that each player is correctly mapped to their corresponding reward:
Example Fix:
This validation ensures that the contract is deployed in a consistent state, with each player correctly mapped to their intended reward, preventing any potential out-of-bounds errors or misallocation of rewards.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.