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

local variable 'retn_node' referenced before assignment #9

Open
huangshichao opened this issue Jun 22, 2021 · 4 comments
Open

local variable 'retn_node' referenced before assignment #9

huangshichao opened this issue Jun 22, 2021 · 4 comments

Comments

@huangshichao
Copy link

I got these error when ruuning with deflat.py:"local variable 'retn_node' referenced before assignment".
I check the script and find out when the function has no "return code"( no matching condition for if supergraph.out_degree(node) == 0 and len(node.out_branches) == 0), the function cannot work.

@cq674350529
Copy link
Owner

Thanks for your feedback. Can you provide your script and binary for me to reproduce easily?

@huangshichao
Copy link
Author

thanks for your reply.
attachment .zip

all the function can be deflated except the trace function(which address is 0x4018B0).
I guess "free function" may affect so that the out-degree-counting and brach-counting results wrong.

@cq674350529
Copy link
Owner

Hi, I had a quick look at it. For a temp fix, you can change the following line to: if supergraph.out_degree(node) == 0:.

if supergraph.out_degree(node) == 0 and len(node.out_branches) == 0:

The retn_node calls another two functions, which breaks the condition len(node.out_branches) == 0.

.text:0000000000401CC5
.text:0000000000401CC5 loc_401CC5:
.text:0000000000401CC5 mov     rdi, offset aGameOver ; "game over"
.text:0000000000401CCF mov     al, 0
.text:0000000000401CD1 call    _printf
.text:0000000000401CD6 mov     edi, 1          ; status
.text:0000000000401CDB mov     [rbp+var_98], eax
.text:0000000000401CE1 call    _exit

I'll check it later why I added an additional condition, maybe for some corner cases.

@huangshichao
Copy link
Author

Thanks a lot!
By reviewing IDA, the function actually ends here. Check the attached picture.
image
it is clear to see that this block has no branches or out degree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants