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

Expression is always false #7495

Closed
AppChecker opened this issue May 15, 2017 · 2 comments
Closed

Expression is always false #7495

AppChecker opened this issue May 15, 2017 · 2 comments

Comments

@AppChecker
Copy link

Hello!

We've checked your code with AppChecker static analyzer and found possible bugs:

  1. https://github.com/radare/radare2/blob/ad54e9ddf18dd88570fec2593920f8f0223d4e8f/libr/anal/p/anal_mips_gnu.c#L194
   else if ((optype & 0x10) == 0x1c) {

0x10 can be represented as 0000 0000 0001 0000
0x1c can be represented as 0000 0000 0001 1100

There is no such value optype, that using operator '&' with 0x10 will rasult 0x1c, as bits number 3 and 4 will be equal to 0 anyway.

  1. https://github.com/radare/radare2/blob/ad54e9ddf18dd88570fec2593920f8f0223d4e8f/libr/anal/p/anal_h8300.c#L222
    https://github.com/radare/radare2/blob/ad54e9ddf18dd88570fec2593920f8f0223d4e8f/libr/anal/p/anal_h8300.c#L333
    ((buf[1] & 0xf0) == 0x08) ? 2 : 1, rd());

0xf0 - 0000 0000 1111 0000
0x08 - 0000 0000 0000 1000
The same as above, the fourth bit as a result of "and" operation will be 0.

Possible defects were found by Echelon Team with AppChecker static analyzer

@radare
Copy link
Collaborator

radare commented May 15, 2017 via email

@AppChecker
Copy link
Author

There is this code in version 1.4.0 also.

@radare radare closed this as completed in f5948a9 May 15, 2017
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