Skip to content

Check length of return data from external calls#2076

Merged
fubuloubu merged 5 commits into
vyperlang:masterfrom
iamdefinitelyahuman:feat-returndatasize
Jul 2, 2020
Merged

Check length of return data from external calls#2076
fubuloubu merged 5 commits into
vyperlang:masterfrom
iamdefinitelyahuman:feat-returndatasize

Conversation

@iamdefinitelyahuman

@iamdefinitelyahuman iamdefinitelyahuman commented Jul 1, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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.

Comment thread vyper/parser/external_call.py
Comment thread vyper/parser/external_call.py Outdated
@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