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

Don't allow 0 width structure members get added #5928

Open
mwales opened this issue Sep 13, 2024 · 1 comment
Open

Don't allow 0 width structure members get added #5928

mwales opened this issue Sep 13, 2024 · 1 comment
Labels
State: Awaiting Triage Issue is waiting for more in-depth triage from a developer

Comments

@mwales
Copy link

mwales commented Sep 13, 2024

Version and Platform (required):

  • Binary Ninja Version: [4.1.5747 enterprise
  • OS: Ubuntu
  • OS Version: 22.04
  • CPU Architecture: x64

Bug Description:
Created a snippet to create vtable structures using existing information from functions that binary ninja had already analyzed. structure looks messed up afterwards. zznop identified that the type i was adding was 0 width, and that I should instead wrap my function type with a Type.pointer to fix.

Steps To Reproduce:

s = types.StructureBuilder.create()
member_func = bv.read_pointer(addr + i)
cur_func = bv.get_function_at(member_func)
...
s.add_member_at_offset(memberName, cur_func.type, offset_val)
bv.define_user_type(vtable_class_name + "_vtable", s)
​

Fixed by instead doing:

s.add_member_at_offset(memberName, Type.pointer(bv.arch,cur_func.type), offset_val)

Expected Behavior:
Adding 0 width items to structure will probably just create confusion

Screenshots/Video Recording:
image

@psifertex
Copy link
Member

For what it's worth, we already do warn in the UI. We'll do some further discussion internally next week to figure out whether this is something we should address purely with documentation or whether we should do something more like warn or except at the python layer

@xusheng6 xusheng6 added the State: Awaiting Triage Issue is waiting for more in-depth triage from a developer label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
State: Awaiting Triage Issue is waiting for more in-depth triage from a developer
Projects
None yet
Development

No branches or pull requests

3 participants