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

wrong quotient value for a originally modulo operation #4586

Open
yangzao opened this issue Apr 17, 2024 · 0 comments
Open

wrong quotient value for a originally modulo operation #4586

yangzao opened this issue Apr 17, 2024 · 0 comments
Labels
bug Something is broken needs-triage Issue has yet to be looked at by a maintainer

Comments

@yangzao
Copy link

yangzao commented Apr 17, 2024

Description

Original code:

((long)((((int)(l_l)) % ((int)(13134243433)))))

Decompiled code:

v7 = v3;
v8 = v7;
v10 = ((v7 * -1983035073 >> 32) + v8 >> 27) - (v8 >> 31);
v3 = 13134243475 - (v8 - v10 * 249341545);

The modulo operation is decompiled into a process of calculating the quotient v10 and then find the remainder.
But the quotient value in the first loop should be 0 while v10 is not.

Steps to reproduce the bug

Files:
5.zip

(compiled program is included as orig_exec)

  1. compile orig.c with GCC and -O0.
  2. decompile the exec with angr.
  3. in the decompiled code, the issue is at the last for loop near the end of func_1.

Environment

No response

Additional context

No response

@yangzao yangzao added bug Something is broken needs-triage Issue has yet to be looked at by a maintainer labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken needs-triage Issue has yet to be looked at by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant