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

Check calldatasize before loading func selector #1606

Merged
merged 3 commits into from
Sep 24, 2019

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Sep 8, 2019

What I did

Fix #1603

How I did it

Implemented the solution from #1603 (comment)

How to verify it

Check tests, also look at IR of following code:

@public
@payable
def blockHashAskewLimitary(v: uint256): # function selector: 0x00000000
  send(msg.sender, self.balance)

@public
def __default__() -> uint256:
  return 1`

Description for the changelog

Fix edge case in function selector with 0 calldata

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@charles-cooper charles-cooper changed the title WIP Check calldatasize before loading func selector Check calldatasize before loading func selector Sep 9, 2019
@charles-cooper charles-cooper changed the title Check calldatasize before loading func selector WIP Check calldatasize before loading func selector Sep 9, 2019
@fubuloubu fubuloubu added the work in progress Work on this PR or issue is not yet complete but reviewers are free to add their input for guidance. label Sep 10, 2019
@charles-cooper charles-cooper changed the title WIP Check calldatasize before loading func selector Check calldatasize before loading func selector Sep 10, 2019
@charles-cooper charles-cooper removed the work in progress Work on this PR or issue is not yet complete but reviewers are free to add their input for guidance. label Sep 10, 2019
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Adding my own approval, and referencing OP's approval from #1603 (comment)

Copy link
Contributor

@davesque davesque left a comment

Choose a reason for hiding this comment

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

Mostly looks good. Left a couple of suggestions for adding comments.

STORE_CALLDATA: List[Any] = ['seq', ['mstore', 28, ['calldataload', 0]]]
STORE_CALLDATA: List[Any] = \
['seq',
['if', ['lt', 'calldatasize', 4],
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to add a note about why this is here. To someone reading the code who's not familiar with the discussion, it might look mysterious.

@@ -57,13 +61,6 @@
)


# Header code
INITIALIZER_LIST = ['seq', ['mstore', 28, ['calldataload', 0]]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you include the deletion of this constant in a separate commit with a message that explains why it was removed? I had to do a bit of poking around to figure out why this was taken out. It looks like it just wasn't used anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah i discovered it was dead code. i can split it into a separate commit

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I remember why I put it in the same commit, it's because it had duplicated code with STORE_CALLDATA and I didn't want the commit to change one of the calldataload without changing the other one.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a note to the commit message to clarify.

@jacqueswww jacqueswww merged commit cf6a872 into vyperlang:master Sep 24, 2019
@charles-cooper charles-cooper mentioned this pull request Sep 25, 2019
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.

Function selector collision is not detected with the "0" selector
4 participants