Bug Description
Unbounded Loop in getSentInvoices / getReceivedInvoices (Potential DoS)
Location
Chainvoice.sol
getSentInvoices()
getReceivedInvoices()
_getInvoices()
Issue Summary
The functions getSentInvoices() and getReceivedInvoices() rely on _getInvoices(), which iterates over the entire invoice ID array:
function _getInvoices(uint256[] storage ids) internal view returns (InvoiceDetails[] memory) {
InvoiceDetails[] memory result = new InvoiceDetails[](ids.length);
for (uint256 i = 0; i < ids.length; i++) {
result[i] = invoices[ids[i]];
}
return result;
}
Fix:Replace getSentInvoices and getReceivedInvoices
function getSentInvoices(
address user,
uint256 offset,
uint256 limit
) external view returns (InvoiceDetails[] memory) {
return _getInvoicesPaginated(sentInvoices[user], offset, limit);
}
function getReceivedInvoices(
address user,
uint256 offset,
uint256 limit
) external view returns (InvoiceDetails[] memory) {
return _getInvoicesPaginated(receivedInvoices[user], offset, limit);
}
Steps to Reproduce
N/A
Logs and Screenshots
N/A
Environment Details
N/a
Impact
High - Major feature is broken
Code of Conduct
Bug Description
Unbounded Loop in getSentInvoices / getReceivedInvoices (Potential DoS)
Location
Chainvoice.solgetSentInvoices()getReceivedInvoices()_getInvoices()Issue Summary
The functions
getSentInvoices()andgetReceivedInvoices()rely on_getInvoices(), which iterates over the entire invoice ID array:Fix:Replace getSentInvoices and getReceivedInvoices
Steps to Reproduce
N/A
Logs and Screenshots
N/A
Environment Details
N/a
Impact
High - Major feature is broken
Code of Conduct