Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect error revert in _unpackCoordinates() function #104

Open
hats-bug-reporter bot opened this issue Sep 15, 2024 · 3 comments
Open

Incorrect error revert in _unpackCoordinates() function #104

hats-bug-reporter bot opened this issue Sep 15, 2024 · 3 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@hats-bug-reporter
Copy link

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);

        }
@hats-bug-reporter hats-bug-reporter bot added the bug Something isn't working label Sep 15, 2024
@benjaminbollen benjaminbollen added the invalid This doesn't seem right label Sep 16, 2024
@benjaminbollen
Copy link
Collaborator

Thanks, but not a low issue

@benjaminbollen
Copy link
Collaborator

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

@benjaminbollen benjaminbollen added invalid This doesn't seem right and removed Invalid - Well-Written Submission labels Sep 16, 2024
@0xdanial
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants