Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
849 stars 194 forks source link

Unable to apply "width parameter" to EnumerationBuilder.create() method in python API #3424

Closed pr0xy-t closed 1 year ago

pr0xy-t commented 1 year ago

Version and Platform (required):

Bug Description: This bug is caused by Python API implementation. (python/binaryninja/types.py#EnumerationBuilder.create) I (want to) create an enum type instance with width=4 using Python API's EnumerationBuilder.create(width=4) method. But EnumerationBuilder.create method return width=8 instance.

Steps To Reproduce:

>>> enum_type_fd = EnumerationBuilder.create(members=[], width=4, arch=Architecture["x86_64"], sign=True, platform=Platform["linux-x86_64"])
>>> enum_type_fd.width
8

Expected Behavior:

>>> enum_type_fd = EnumerationBuilder.create(members=[], width=4, arch=Architecture["x86_64"], sign=True, platform=Platform["linux-x86_64"])
>>> enum_type_fd.width
4

Screenshots: Screenshot from 2022-08-22 20-19-00

Additional Information: This bug is caused by overwritten width parameter in create method. The width parameter being passed to _width in the EnumerationBuilder.create method (Line 349) and next then overwritten by arch.address_size (Line 351) or the constant 4 (Line 353). Screenshot from 2022-08-22 20-22-50

plafosse commented 1 year ago

Thanks for the bug report. This should be fixed in 3.1.3645. We actually have extensive unit tests on this stuff but somehow missed that edge case!

pr0xy-t commented 1 year ago

Thank you for your quick response!!!