sherlock-audit / 2023-12-dodo-gsp-judging

6 stars 5 forks source link

bareli - Division by Zero #149

Closed sherlock-admin2 closed 10 months ago

sherlock-admin2 commented 10 months ago

bareli

medium

Division by Zero

Summary

Division by Zero: None of the division functions (div, divFloor, divCeil, reciprocalFloor, reciprocalCeil) check for division by zero, which will cause a revert. It is important to ensure that the divisor is never zero when calling these functions.

Vulnerability Detail

div, divFloor, divCeil, reciprocalFloor, reciprocalCeil will revert as we can be be dividing by 0.

Impact

Function will be revert as division functions (div, divFloor, divCeil, reciprocalFloor, reciprocalCeil) doesnot check for division by zero,

Code Snippet

https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/main/dodo-gassaving-pool/contracts/lib/DecimalMath.sol#L30

Tool used

Manual Review

Recommendation

use require statement to check for the division by zero.

nevillehuang commented 10 months ago

Invalid, division by zero will revert by natively by solidity, no need for explicit require check