Vector35 / binaryninja-api

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

`analysis.limits.minStringLength` does not work on small values #4697

Closed xusheng6 closed 11 months ago

xusheng6 commented 1 year ago

First reported in: https://github.com/Vector35/binaryninja-api/discussions/4679

helloworld.zip

Screenshot 2023-10-20 at 9 35 12 AM

The string at 0x2012 is a short one, ar.

Screenshot 2023-10-20 at 9 32 33 AM

However, even if I set analysis.limits.minStringLength to 2, the string still does not get defined.

P.S.: this issue would be otherwise fixed by #4400, since we have type library for printf, and its first parameter is a const char*, which would cause the data var at 0x2012 to be defined as a string.

xusheng6 commented 1 year ago

Well, this is more complex than I have expected. First of all, the string does get detected properly, that if I check the output of bv.strings, I can see the string:

<AsciiString: 0x2012, len 0x2>,

Now the real problem is why we did not define a data variable at 0x2012.

xusheng6 commented 1 year ago

Oh so the code to define these string data variables do not use the already collected string list -- instead it uses some ad-hoc code that uses the constant value 4 and does not check for the analysis.limits.minStringLength setting. Also the code does not define UTF8/UTF16/UTF32 string data vars. Once this is fixed, it should bring a noticeable usability improvement.