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

Crashes due to wrong hexadecimal format #52

Open
SteMak opened this issue Dec 17, 2024 · 0 comments
Open

Crashes due to wrong hexadecimal format #52

SteMak opened this issue Dec 17, 2024 · 0 comments

Comments

@SteMak
Copy link

SteMak commented Dec 17, 2024

The bytes_required function in sfs_generator/asm_bytecode.py may throw error due to wrongly formatted hexadecimal starting with x prefix

ValueError: invalid literal for int() with base 16: 'xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618'

This happens due to int(string, 16) expects hexadecimal to start with 0x or without prefix at all

I'm not sure where the issue is coming from, I've used --asm-json (--singe-json) mod with quite large contract and the thrown hexadecimal literal is not presented in the asmjson

To resolve the issue, it is necessary to catch where wrong formatted hex value is coming from
The following change can be applied as a hotfix

         if is_push0(self.disasm, self.value):
             return 1
         elif self.disasm == "PUSH":
+            if len(self.value) >= 1 and self.value[0] == "x":
+                self.value = self.value[1:]
             decimal_value = int(self.value, 16)
         else:
             decimal_value = None
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

1 participant