radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
19.71k stars 2.94k forks source link

r2ghidra: type casted value recovered as 0 #22855

Closed yangzao closed 4 weeks ago

yangzao commented 4 weeks ago

Environment

Thu Apr 18 08:05:01 PM MDT 2024
radare2 5.8.9 31711 @ linux-x86-64
birth: git.5.8.8-1074-gbe75b2d9ee 2024-02-13__17:26:56
commit: be75b2d9ee0701582aae047c2a717c4a64d6503e
options: gpl -O1 cs:5 cl:2 make
Linux x86_64

Description

When using R2Ghidra to decompile a program, a type casted value is recovered as 0 Original code:

(long)((((int)(9876543)) % ((int)(l_l))))

Decompiled code:

0 % iStack_20

((int)(9876543)) becomes 0 (iStack_20 corresponds to l_l)

Test

Files: 3.zip

commands used:

r2 orig_exec
aaa
pdg @ sym.func_1

the issue is at the line (iStack_20 = (iStack_20 * iStack_20 ...) before the last for loop.

trufae commented 4 weeks ago

Please, Reopen the ticket in the r2ghidra repo