joern icon indicating copy to clipboard operation
joern copied to clipboard

ghidra2cpg - argument Index issue

Open zi0Black opened this issue 3 years ago • 4 comments

I'm working with an ARM binary, and with the Joern version 1.1.385 I encounter the following issue. As you can see from the screenshots I have a sprintf call where the second (2) argument is a Literal but if I try to access it in where clause nothing is returned (screenshot n°2). I think the issue is related on the number of arguments Joern identified, and subsequntialy this affect the argument index (screenshot n° 3).

image

image

Argument index is set to -1 and those result are obtained only if I access the first argument in the where clause. image

The behaviour is completely different if you import some C code, the following two screenshot for comparison.

From binary (all arguments index are 1): image

From source code: image

zi0Black avatar Dec 14 '21 09:12 zi0Black

Hi @zi0Black,

thanks for the issue. Can you share your binary or something that i can test against?

I guess it is an ARM 32bit binary?

itsacoderepo avatar Dec 14 '21 10:12 itsacoderepo

I can't share the binary :(

If you can't reproduce it with a generic ARM binary, we can figure out how to share something useful.

Yes, it's ARM 32bit.

zi0Black avatar Dec 14 '21 10:12 zi0Black

I'll try to reproduce the behavior with a random 32bit ARM binary.

itsacoderepo avatar Dec 14 '21 10:12 itsacoderepo

This is not a complete fix but a step into the right direction: https://github.com/joernio/joern/commit/c6471d473c853238dde535ab1c66c4cef8ce2380

itsacoderepo avatar Jan 12 '22 16:01 itsacoderepo