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

未關閉
#8,645 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
c, cpp

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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)

主要語言
C++
星號
1.3k
分支
304
平均合併
2 天 20 小時
30 天內合併 PR
10

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Vector35/binaryninja-api 的其他 Issue

查看 Vector35/binaryninja-api 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。