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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function selector is incorrect for structs #77

Closed
mds1 opened this issue Jun 18, 2021 · 4 comments 路 Fixed by #128
Closed

Function selector is incorrect for structs #77

mds1 opened this issue Jun 18, 2021 · 4 comments 路 Fixed by #128
Labels
bug Something isn't working

Comments

@mds1
Copy link

mds1 commented Jun 18, 2021

Hey again @tintinweb鈥擨 know in #68 you mentioned the signature extraction is hacky and you don't expect many people use it, but actually it's probably the feature I use most, so here's another related issue 馃榿

The issue:

  • The function selector for this method is 0x9120491c
  • But the extension reports 0xe1acd927

In this case the method linked is an array of structs. I think I've also seen regular structs and interfaces (e.g. function someMethod(IERC20 _address)) give the wrong function signature, though I don't have an example handy鈥擨 can double-check and confirm this if you need

@jjmr007
Copy link

jjmr007 commented Sep 8, 2021

I find this auditor as a very useful tool.

The problem with structs in function selector is not the only issue: it don't parse by any mean the interfaces. May be I have to open a new issue regarding this problem?

E.g.: if we use Remix in a contract with the method:

function rateByPath(IERC20[] calldata _path, uint256 _amount)

It is parsed as: "convertByPath(address[],uint256,uint256,address,address,uint256)", with the selector:

"b77d239b": "convertByPath(address[],uint256,uint256,address,address,uint256)",

But the vscode-solidity-auditor do the wrong calculation:

ded49702: "convertByPath(IERC20[],uint256,uint256,address,address,uint256)"

@fabiohild
Copy link

As another note, for fixed sized arrays the wrong function sig is shown too:

For "function arr(uint[2] memory param)" it returns "bfceb977 => arr(uint256[])"

Correct output would be "d1578977 => arr(uint256[2])"

@tintinweb
Copy link
Member

I guess I really have to refactor the funcsig extraction part. If anyone want's to take this on, I'm open for PRs :)

@aliveli186
Copy link

"funcSig" over a function and "funcSigs" at the top of the file report 2 different signature values for the same function.
The problem arises if a function has in parameter of struct array.
The "funcSig" even reports the struct array parameter as address array while the "funcSigs" reports it as struct array.
Signature reporting feature is a useful feature, and I would like it to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants