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

compile_lll.py: inconsistency in checking invalid cases #449

Closed
daejunpark opened this issue Nov 9, 2017 · 1 comment
Closed

compile_lll.py: inconsistency in checking invalid cases #449

daejunpark opened this issue Nov 9, 2017 · 1 comment

Comments

@daejunpark
Copy link
Contributor

What's your issue about?

Inconsistency in checking invalid cases in compile_lll.py.

For the with variable lookup, it rejects immediately when the with statement is too deep:
https://github.com/ethereum/viper/blob/b1fe12ddd8706ef3340a103916e3d3f2cc95ceef/viper/compile_lll.py#L50-L54
but for the with variable update, it does not check at all, which may lead to generate an invalid/wrong opcode (e.g., if the depth is 17, then internally it will generate SWAP17 (doesn't exist) that will end up being encoded as 0xa0, which is LOG0):
https://github.com/ethereum/viper/blob/b1fe12ddd8706ef3340a103916e3d3f2cc95ceef/viper/compile_lll.py#L55-L60

However, I couldn't find an example program that leads to such a deep with statement. It might not be possible at this moment, but it would be good to fix for later.

How can it be fixed?

Add the following check in the case of code.value == "set":

     if height - withargs[code.args[0].value] > 16: 
         raise Exception("With statement too deep") 

Cute Animal Picture

       \/)/)
     _'  oo(_.-. 
   /'.     .---'
 /'-./    (
 )     ; __\
 \_.'\ : __|
      )  _/
     (  (,.
   mrf'-.-'
@DavidKnott
Copy link
Contributor

@daejunpark Thanks for brining this up, I'll make a pr to fix this.

DavidKnott added a commit that referenced this issue Nov 16, 2017
Fix issue #449: inconsistency in checking invalid cases
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

No branches or pull requests

2 participants