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 length of return data from external calls #2076

Merged
merged 5 commits into from
Jul 2, 2020

Conversation

iamdefinitelyahuman
Copy link
Contributor

@iamdefinitelyahuman iamdefinitelyahuman commented Jul 1, 2020

What I did

How I did it

  • Add a check that RETURNDATASIZE > expected length -1 after making a call.
  • In cases where we are expecting return data, do not include the check involving EXTCODESIZE. An address that is not a contract will not return any data, so this check isn't required.
  • For dynamic types (bytes and string), assert that the length of the returned data does not exceed the max allowable length for the contract type

It is still possible for a call to return more data than expected by the interface. This is consistent with how Solidity handles the check.

How to verify it

Run the tests. I added a few test cases, and removed one that is no longer valid.

Cute Animal Picture

image

@codecov-commenter
Copy link

Codecov Report

Merging #2076 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2076   +/-   ##
=======================================
  Coverage   85.04%   85.05%           
=======================================
  Files          83       83           
  Lines        8239     8243    +4     
  Branches     1985     1987    +2     
=======================================
+ Hits         7007     7011    +4     
  Misses        735      735           
  Partials      497      497           
Impacted Files Coverage Δ
vyper/parser/external_call.py 81.69% <100.00%> (+1.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0b7c70...4e4e55c. Read the comment docs.

@fubuloubu fubuloubu merged commit 35f424d into vyperlang:master Jul 2, 2020
@iamdefinitelyahuman iamdefinitelyahuman deleted the feat-returndatasize branch July 4, 2020 14:54
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.

Vyper doesn't check RETURNDATASIZE on external calls No length check on bytes and string arrays
3 participants