hats-finance / Circles-0x6ca9ca24d78af44582951825bef9eadcb210e5cf

Circles Protocol contracts
https://aboutcircles.com
GNU Affero General Public License v3.0
0 stars 0 forks source link

Incorrect error revert in `_unpackCoordinates()` function #104

Open hats-bug-reporter[bot] opened 2 months ago

hats-bug-reporter[bot] commented 2 months ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0xb7c453dded125381b30b64a92528293a819041fa019bf5eb4e890399917b5bfc Severity: low

Description: Description\ The function _unpackCoordinates() contains if() condition that checks if:

  if (_packedData.length != _numberOfTriplets * 6) {
            // Invalid packed data length
            revert CirclesArraysLengthMismatch(_packedData.length, _numberOfTriplets, 6);
        }

However, incorrect error message is being reverted in CirclesArraysLengthMismatch(_packedData.length, _numberOfTriplets, 6);.

_numberOfTriplets is multiplied by 6 in the if condition, but in the error message, it is only _numberOfTriplets, causing a mismatch between the logic and the revert error.

Recommendation\ To fix this, the revert error message should correctly reflect the logic as follows:

  if (_packedData.length != _numberOfTriplets * 6) {
            // Invalid packed data length
-            revert CirclesArraysLengthMismatch(_packedData.length, _numberOfTriplets, 6);
+            revert CirclesArraysLengthMismatch(_packedData.length, _numberOfTriplets * 6, 6);

        }
benjaminbollen commented 2 months ago

Thanks, but not a low issue

benjaminbollen commented 2 months ago

Also, just note that the error reads CirclesArraysLengthMismatch it does not state that both need to be equal, that is your misinterpretation.

0xdanial commented 2 months ago

@benjaminbollen thanks for your comment.

I know the CirclesArraysLengthMismatch error does not state that both values need to be equal, and it's technically impossible because _numberOfTriplets is always multiplied by 6. However, my point is that this error reverts due to incorrect mismatch values.

For example: If _packedData.length = 12 and _numberOfTriplets = 3,

the function reverts due to this logic: 12 != 18 (3 * 6) => revert

However, the error message will show a mismatch between 12 and 3, while the actual logic compares 12 and 18.

This issue highlights the mismatch between the actual logic and the error message, and I think it can be classified as a Low severity issue.

Thanks.