The createOffer
function is responsible for creating new offers and updating various mappings ( offerInfoMap
, stockInfoMap
) with the relevant offerId
. However, a critical issue has been identified where the offerId
is incremented prematurely, before the updates to these mappings are finalized. This early increment causes incorrect offerId
values to be stored in the mappings, leading to data inconsistencies, potential loss of offer tracking, and operational errors within the system.
Within the createOffer
function, the offerId
is incremented too early in the process, before the offerInfoMap
, and stockInfoMap
are updated. This premature increment means that these mappings are updated with an incorrect offerId
, which does not correspond to the actual offer being created.
The incorrect offerId
stored in these mappings results in data inconsistencies across the system. The mappings may reference non-existent or incorrect offers, leading to failures in offer tracking, incorrect data retrieval, and potential errors in subsequent operations that rely on accurate offer information.
Manual Review
The increment of the offerId should be done at the end of the function or after the mappings has been updated.
I believe this is valid low severity, although there is inconsistency here when using the correct `offerId` for assigning offerIds and generating the unique addresses as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L67-L69), this is purely an accounting error for offerIds. If we generate the offerId using current `offerId - 1`, the appropriate listing/taker orders can still be created against those offers.
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.