Vector35 / Vector35/binaryninja-api

Undefining a structure member sometimes causes the related expression to have a wrong type

Open
#2,453 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: Core Impact: High
Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Description

#include <stdio.h>
#include <inttypes.h>
#include <stdbool.h>

struct B
{
    uint64_t a;
    bool b;
    uint64_t c;
};

struct B b;

int main()
{
    b.b = true;
    b.c = 0x12345678;
    return 0;
}

I got some correct output like this:

>>> current_mlil[1]
<il: [0x4030].q = 0x12345678>
>>> current_mlil[1].operands
[<il: 0x4030>, <il: 0x12345678>]
>>> current_mlil[1].operands[1].expr_type
<type: uint64_t>

Then if I go to type view and undefine the member c of the struct B, the expr_type changes and it is wrong:

>>> current_mlil[1].operands[1].expr_type
<type: struct B>

I am really expecting the expr_type go back to void, which was the type of before I apply the type of struct B.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied C reproducer and inspect current_mlil[1].operands[1].expr_type before and after undefining member c in the type view. Trace how the undefinition updates the related MLIL expression and verify that the operand type returns to void rather than struct B.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.