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

[Codegenerator] Invalid Condition #59

Closed
ebehner opened this issue Feb 3, 2022 · 3 comments · Fixed by #101
Closed

[Codegenerator] Invalid Condition #59

ebehner opened this issue Feb 3, 2022 · 3 comments · Fixed by #101
Assignees
Labels
bug Something isn't working priority-high High priority issue

Comments

@ebehner
Copy link
Collaborator

ebehner commented Feb 3, 2022

What happened?

Currently, when decompiling function main of fmt.zip the decompilation process crashes due to an invalid condition.

More precisely, the reaching condition of an AST node is evaluated as false because the type of a constant is wrong. (The problem with type propagation is tracked in Issue #42.)
Nevertheless, the program should not crash. The program occurs because the function _condition_string does not assume that a condition is true or false.

Proposal
There are multiple options for this problem.

  1. In general, if a condition is false, then we can simply remove the true branch and execute always the false branch, i.e., we can substitute the condition node with the false branch. Symmetrically, one would replace each condition node with condition true by its true branch. But, in cases like this where the condition should not be false, we may lose content we do not want to lose.
  2. We simply have a condition that is false or true and add this scenario to the function _condition_string.

In both cases, a warning could be nice.

How to reproduce?

Try to decompile main in fmt.zip

Affected Binary Ninja Version(s)

2.4.2846

@ebehner ebehner added bug Something isn't working priority-high High priority issue labels Feb 3, 2022
@ebehner
Copy link
Collaborator Author

ebehner commented Feb 21, 2022

Proposal 2 and a new Issue that also implements 1 with config option.

@ebehner ebehner assigned ebehner and steffenenders and unassigned ebehner Feb 21, 2022
@steffenenders
Copy link
Member

/cib

@github-actions
Copy link
Contributor

Branch issue-59-_Codegenerator_Invalid_Condition created!

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

Successfully merging a pull request may close this issue.

2 participants