Unnecessary addition operation at function call in decompiled code

Aperta
#3,578 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
cpp

Direzione di ricerca

Review the reported decompiled C and the strcpy_s disassembly in this issue, focusing on the argument represented as wot + 0x28. Reproduction will require an equivalent binary or test case, which the report does not provide; done means the decompiler emits the expected 0x28 size without the unnecessary variable or addition.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Component: Core IL Optimization Impact: Medium
  • Binary Ninja Version: 3.2.3782-dev
  • OS: Windows 10 x64

Bug Description:

int64_t var_d8 = -2
void var_108
int64_t rax_1 = __security_cookie ^ &var_108
BOOL wot = TryEnterCriticalSection(&this->Lock)
if (wot != 0)
    this->vft->field_c0(this)
    this->vft->Stop(this)
    this->field_70 = 0
    LeaveCriticalSection(&this->Lock)
else
    char Destination[0x28]
    // BUG here
   // wot + 0x28?
   // wot = 0, 0 + 0x28, why?
    strcpy_s(&Destination, zx.q(wot + 0x28), "Stop")
    int64_t rcx_3 = this->field_510
    if (rcx_3 == 0)
        void*** rax_2 = operator new(0x40)
        void*** var_d0_1 = rax_2
        if (rax_2 == 0)
            rcx_3 = 0
        else
            rcx_3 = sub_180093810(rax_2)
        this->field_510 = rcx_3
    (*(*rcx_3 + 8))(rcx_3, &Destination, 0xa8, 0, 0xffffffff)
__security_check_cookie(rax_1 ^ &var_108)

Disassembly of strcpy_s call:

lea     r8, [rel data_1800ca610]  {"Stop"}
lea     edx, [rax+0x28]
lea     rcx, [rsp+0x40 {Destination}]
call    qword [rel strcpy_s]

Expected Behavior:
I expect it to show only 0x28

Additional Information:
IDA does not even creates wot variable.

 if ( TryEnterCriticalSection(&this->Lock) )
  {
    this->vft->sub_180099A50(this);
    this->vft->Stop(this);
    this->field_70 = 0;
    LeaveCriticalSection(&this->Lock);
  }
  else
  {
    strcpy_s(Destination, 0x28ui64, "Stop");

I can not share the binary unfortunately.

Lingua principale
C++
Stelle
1.3k
Fork
298
Merge medio
5g 5h
PR unite (30g)
19

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Vector35/binaryninja-api

Tutte le issue di Vector35/binaryninja-api

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.