Pseudo C: zero-extended 16-bit sum printed with casts on the operands, losing the 16-bit truncation

Offen
#8,645 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
c, cpp

Rechercherichtung

The payload names no source files or tests, and the Pseudo C cast emission is likely in the closed-source decompiler core, not this public API repo. Start from the disassembly in the body: movzx eax, ax truncates the sum, and the Pseudo C drops that truncation by casting the operands instead. Reproduce it with a small x64 sample and check whether the outer (uint32_t) cast needs a (uint16_t) inside it. Done means the expected output shown in the issue is produced for that sample.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Version and Platform (required):

  • Binary Ninja Version: 6.0.10601-Stable
  • Edition: Non-Commercial
  • OS: Windows on ARM
  • OS Version: 26H1
  • CPU Architecture: x64 target

Bug Description:
A 16-bit truncation of a sum (movzx eax, ax after two 32-bit adds) is printed in Pseudo C as a sum of uint16_t-cast operands with an outer uint32_t cast. But uint16_t is storage type by C language standard. Under C’s integer promotion rules that expression computes the full, untruncated sum, so the Pseudo C has different semantics from the binary.

Disassembly:

140001076  movzx   r9d, r8w          ; a = h & 0xFFFF
14000107f  shr     r8d, 0x10         ; b = h >> 16
140001088  add     eax, r8d          ; eax = n + b   (eax = strlen result)
14000108b  add     eax, r9d          ; eax = n + b + a
14000108e  movzx   eax, ax           ; c = (n + b + a) & 0xFFFF
140001091  mov     dword [rsp+0x28], eax

Pseudo C output:
(uint32_t)((uint16_t)rax_1 + (uint16_t)r8_2 + (uint16_t)r9_1)

Expected Pseudo C output:
(uint32_t)(uint16_t)((uint16_t)rax_1 + (uint16_t)r8_2 + (uint16_t)r9_1)

Vorherrschende Sprache
C++
Sterne
1.3k
Forks
304
Ø Merge
2 T. 20 Std.
Gemergte PRs (30 T.)
10

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Vector35/binaryninja-api

Alle Issues in Vector35/binaryninja-api

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.