If the current amount_raised
is close to max(u64)
and the contribution amount makes this number over u64, it will overflow.
This function https://github.com/CodeHawks-Contests/2025-03-rustfund/blob/main/programs/rustfund/src/lib.rs#L50 does not check for overflow. Moreover, the max goal is limited by max(u64)
Prevent campaigns from having a goal over max(u64)
and prevents the amount_raised
to be over max(u64)
Manual review
Use a bigger type for goal
and/or amount_raised
Check for overflow and return correct error in case of overflow (ErrorCode::CalculationOverflow)
The max value of u64 is: 18,446,744,073,709,551,615 or around 18.4 billion SOL, given that the total supply of SOL on Solana is 512.50M, the scenario when the `contribute` function will revert due to overflow is very very unlikely to happen. Therefore, this is informational finding.
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.