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

Arguments Overflow in encodeABI #1123

Closed
melnikaite opened this issue Oct 18, 2017 · 2 comments
Closed

Arguments Overflow in encodeABI #1123

melnikaite opened this issue Oct 18, 2017 · 2 comments
Labels
Enhancement Includes improvements or optimizations

Comments

@melnikaite
Copy link

c = new web3.eth.Contract([{"constant":true,"inputs":[{"name":"a","type":"bytes32"},{"name":"b","type":"bytes32"}],"name":"bIsWrong","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function","stateMutability":"view"}])

c.methods.bIsWrong('a'.repeat(64), 'b'.repeat(64)).encodeABI()
returns
0x020e2724aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
which is fine

c.methods.bIsWrong('a'.repeat(65), 'b'.repeat(64)).encodeABI()
returns
0x020e2724aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
which is wrong, because second argument gets wrong value a000000000000000000000000000000000000000000000000000000000000000

Expected behaviour is raising error, because first argument exceeded length of specified in ABI type

@frozeman
Copy link
Contributor

Good catch, if you like you can raise a PR to enhance input type checking.

@frozeman frozeman added Enhancement Includes improvements or optimizations help wanted labels Oct 19, 2017
frozeman pushed a commit that referenced this issue Oct 24, 2017
* Fix for Bug #1123

* Trigger travis

* Removed a bogus test for `bytes64`
@frozeman
Copy link
Contributor

Should be fixed in the next release.

nachomazzara pushed a commit to nachomazzara/web3.js that referenced this issue Jun 4, 2020
* Fix for Bug web3#1123

* Trigger travis

* Removed a bogus test for `bytes64`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Includes improvements or optimizations
Projects
None yet
Development

No branches or pull requests

2 participants