The giveLoan function in the Lender.sol contract accepts two arrays, loanIds and poolIds, but it fails to validate that the lengths of these two input arrays match. In case of a mismatch, this can lead to unexpected behaviours and potential disruptions in the functioning of the contract.
The code instance of potential issue is in the giveLoan() function in Lender.sol contract:
As seen this function attempts to match loan IDs to pool IDs based on their respective array indices. If the lengths of the loanIds and poolIds arrays do not match, this could lead to accessing an out-of-bounds index, which in turn might lead to exceptions or undefined behaviour.
If the lengths of the input arrays loanIds and poolIds do not match, an exception or undefined behaviour could occur, disrupting the expected operation of the giveLoan function.
Manual Audit
Add an input validation step in the giveLoan function to ensure the lengths of the input arrays loanIds and poolIds match before proceeding with the operations. If the lengths do not match, the function should revert with a meaningful error message.
This check could look like:
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.