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

Do not crash when trying to encode too large arrays #5188

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

erak
Copy link
Collaborator

@erak erak commented Oct 10, 2018

Fixes #5058.

@@ -1698,6 +1698,8 @@ bool ArrayType::operator==(Type const& _other) const

bool ArrayType::validForCalldata() const
{
if (auto arrayBaseType = dynamic_cast<ArrayType const*>(baseType().get()))
Copy link
Contributor

@chriseth chriseth Oct 10, 2018

Choose a reason for hiding this comment

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

Wouldn't it be better to call arrayBaseType->validForCalldata() here?
A counterexample could be uint[2**30][2**30][]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not calling arrayBaseType->validForCalldata() would still result in an assertion for function f(uint[2**30][2**30][] memory) public pure {}. The same code does not assert when ABIEncoderV2is enabled.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I'm still puzzled. I was suggesting to call arrayBaseType->validForCalldata(); regardless of the base type and returning false if it returned false. As it is now, we do not check the encoded size, which means something like [2**16][2**16] would not be caught, I think.

@codecov
Copy link

codecov bot commented Oct 10, 2018

Codecov Report

Merging #5188 into develop will increase coverage by <.01%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5188      +/-   ##
===========================================
+ Coverage    88.01%   88.01%   +<.01%     
===========================================
  Files          322      318       -4     
  Lines        32489    31909     -580     
  Branches      3863     3766      -97     
===========================================
- Hits         28594    28086     -508     
+ Misses        2592     2551      -41     
+ Partials      1303     1272      -31
Flag Coverage Δ
#all 88.01% <50%> (ø) ⬆️
#syntax 28.69% <50%> (+0.78%) ⬆️

@erak erak self-assigned this Oct 12, 2018
@chriseth chriseth merged commit 437467a into develop Oct 30, 2018
@axic axic deleted the large-array-encoding branch October 30, 2018 14:33
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.

2 participants