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
Collaborator

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
@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 force-pushed the charles-cooper:check_calldatasize branch from 8839113 to f9155a5 Sep 10, 2019
Copy link
Member

fubuloubu left a comment

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

@fubuloubu fubuloubu requested review from jacqueswww and davesque Sep 10, 2019
Copy link
Contributor

davesque left a comment

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],

This comment has been minimized.

Copy link
@davesque

davesque Sep 17, 2019

Contributor

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]]]

This comment has been minimized.

Copy link
@davesque

davesque Sep 17, 2019

Contributor

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?

This comment has been minimized.

Copy link
@charles-cooper

charles-cooper Sep 19, 2019

Author Collaborator

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

This comment has been minimized.

Copy link
@charles-cooper

charles-cooper Sep 19, 2019

Author Collaborator

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.

This comment has been minimized.

Copy link
@charles-cooper

charles-cooper Sep 19, 2019

Author Collaborator

I added a note to the commit message to clarify.

@charles-cooper charles-cooper force-pushed the charles-cooper:check_calldatasize branch from f9155a5 to 8531af2 Sep 19, 2019
@charles-cooper charles-cooper requested a review from davesque Sep 19, 2019
@jacqueswww jacqueswww merged commit cf6a872 into vyperlang:master Sep 24, 2019
3 checks passed
3 checks passed
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: py36-core Your tests passed on CircleCI!
Details
ci/circleci: py37-core Your tests passed on CircleCI!
Details
@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
Projects
None yet
4 participants
You can’t perform that action at this time.