Open d0mnik opened 3 years ago
As a temporary fix for the second issue (which is caused by two different paths to the basic block at 0x8048a30
with different stack alignment) you can right-click on the branch at 0x80489bd
and select "always branch". You lose the first conditional, but it results in the stack being properly aligned which lets the function argument detection succeed for the remainder of the function. I don't know enough about the internal stack alignment calculation to know whether this is a bug or simply a missing analysis feature but I'll talk to others on the team.
Thanks for the detailed bug report.
Another related issue here is the 32bit x86 libc library isn't shipping as you can see the 64bit binary doesn't have the same problems (and the register based calling convention of course means that the stack-misalignment doesn't occur)
You can see the status of those libraries (which are actively being worked on) here: https://github.com/Vector35/binaryninja-api/issues/1495
(I removed my original paragraph here since there is still an issue with the 32bit x86 version having mis-aligned stack that removing the conditional branch at the top does still work-around)
Not quite sure why, but the decompilation of the 64bit binary doesnt quite look the same? It appears to be vastly different from the Hex-Rays decompilation.
I didn't have the exact source of the one you were using so I just searched for a different binary from CMU. Found this: http://csapp.cs.cmu.edu/3e/bomb.tar which may or may not be the same binary if that's what you mean?
If you've got source to the 32bit one you had above and can rebuild as 64bit that should also show the correct stack alignment but there's so many different bomblab variants out there it's possible it's a different one.
Though now that you mention it, comparing IDAs output on that sample they do decidedly worse on the main function.
versus:
I didn't have the exact source of the one you were using so I just searched for a different binary from CMU. Found this: http://csapp.cs.cmu.edu/3e/bomb.tar which may or may not be the same binary if that's what you mean?
Oh. I just naturally assumed it was the same bomblab but in 64bit, and wondered why the output was so different. Did not realize you were referring to the stack misalignment.
Yeah the stack misalignment here is due to us getting the wrong parameter count for fopen. This would have been solved by type libraries or improvements on our stack resolution algorithm
Binary Ninja Version 2.4.2846 Personal
Describe the bug
Binary Ninja does not recognize an array access, resulting in the creation of stack variables, throwing off decompilation.
To Reproduce Steps to reproduce the behavior:
sub_8048b48
Screenshots
Binary Ninja does not recognize that the
var_1c
array is being recognized and thus createsvar_20
, whose value is not set anywhere.Hex-Rays more accurate decompilation:
Binary Ninja also fails to recognize a stack variable being passed as arguments to a function call, resulting in inaccurate decompilation
esp_1
is throwing off the decompilation.More accurate Hex-Rays decompilation:
Version and Platform (required):
Additional context The binary can be found here: https://drive.google.com/file/d/14X1Y7Dj4sn95giIKaKdbJJ6N6P1-n2mj/view?usp=sharing