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

changed the checks for generateOrder's return data ABI encoding #57

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

Saw-mon-and-Natalie
Copy link
Collaborator

Comment on lines +910 to +920
// If valid length, check that offsets word boundaries are within returndata.
let invalidOfferOffset :=
gt(
add(offsetOffer, OneWord),
returndatasize()
)
let invalidConsiderationOffset :=
gt(offsetConsideration, returndatasize())
gt(
add(offsetConsideration, OneWord),
returndatasize()
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed these checks too, since the offsets might be less than returndatasize() but the diffs might be less than one word which would cause reading passed the returndatasize().

Comment on lines 947 to 954
// Don't continue if returndatasize exceeds 65535 bytes
// or is greater than the calculated size.
// or less than the end offsets.
invalidEncoding :=
or(
gt(
or(offerLength, considerationLength),
generateOrder_maximum_returndatasize
),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check does not match with the comment. @0age

The comment says:

// Don't continue if returndatasize exceeds 65535 bytes

But here we are checking the or(offerLength, considerationLength) against generateOrder_maximum_returndatasize

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we definitely still want to keep the constraint on array length just to protect against funky overflow scenarios in the preceding logic; the size of returndata is still somewhat constrained by comparison against the derived offsets as well

I'd say generateOrder_maximum_returned_array_length would be more accurate for the name; and comment could just say // Don't continue if either offer or consideration length exceeds 65535 or something

Copy link
Contributor

@0age 0age left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aside from the one named constant & comment fix, LGTM

@0age 0age merged commit be2140a into main Mar 5, 2024
4 checks passed
@0age 0age deleted the generateOrder-abi-invalid-encoding branch March 5, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants