The division by activeFertilizer without checking if it is zero can result in a division by zero error.
If activeFertilizer is zero, a division by zero will occur, causing the transaction to fail. The function does not include a check to prevent this condition here is the vulnerable line :
Any subsequent operations that depend on newBpf and the loop where newTotalBpf is compared against firstEndBpf would be affected if newBpf is derived from a division by zero.
Here is a Scenario Demonstrating the Bug
Let’s say we have :
Then we run the function rewardToFertilizer with these values and as result when activeFertilizer set to 0, the line
uint256 newBpf = maxNewFertilized.div(s.activeFertilizer)
will cause a division by zero error.
division by zero can cause the transaction to revert, leading to inconsistencies and failed transactions.
Manual review
Need to check to ensure that activeFertilizer is not zero before performing the division.
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.