sherlock-audit / 2024-01-looksrare-judging

3 stars 0 forks source link

bareli - _unsafeSubtract can led to error #146

Closed sherlock-admin2 closed 7 months ago

sherlock-admin2 commented 7 months ago

bareli

medium

_unsafeSubtract can led to error

Summary

we are not verifying the _unsafeSubtract implementation as : uint256 currentEntryIndex = currentEntryIndexArray[_unsafeSubtract(count, 1)];

Vulnerability Detail

uint256 currentEntryIndex = currentEntryIndexArray[_unsafeSubtract(count, 1)]; here count can be 0. then we will get an issue.

Impact

Code Snippet

https://github.com/sherlock-audit/2024-01-looksrare/blob/main/contracts-yolo/contracts/YoloV2.sol#L1286

Tool used

Manual Review

Recommendation

verify count is greater than 0.

nevillehuang commented 7 months ago

Invalid, count will always be at least 1 or greater than 1, given there must at least be 2 participants per game.