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

Detect array buffer lengths automatically #6399

Closed
Exiled1 opened this issue Feb 7, 2025 · 2 comments
Closed

Detect array buffer lengths automatically #6399

Exiled1 opened this issue Feb 7, 2025 · 2 comments
Labels
Component: Core Issue needs changes to the core Effort: Medium Issue should take < 1 month Impact: Medium Issue is impactful with a bad, or no, workaround

Comments

@Exiled1
Copy link

Exiled1 commented Feb 7, 2025

What is the feature you'd like to have?
Please provide a clear and concise description of what you want.

The ability for binary ninja to analyze a function, notice a buffer of a static size, and fill in the type and size of the array would be a very nice to have feature. Currently for basically every single array buffer, binary ninja just shows it as a void* and calls it good. The problem with this is that the void type is greyed out and combined with the fact that binja sometimes thinks that a variable isn't being used and greying out the whole line, the manual retyping process can get annoying. Ghidra has had this form of length auto detection for absolute ages, same with Ida, so it'd be nice for binary ninja to do the same.

Is your feature request related to a problem?
If applicable, please provide a clear and concise description of what the problem is.
The problem is mainly visibility. For the most part this is a nice to have but not really a deal breaker.

Are any alternative solutions acceptable?
Please provide a clear and concise description of any alternative solutions or features you've considered.

Yes, usually these types of buffers are next to a malloc call and it's normally pretty clear to figure out the size based on nearby context, then change the type to be something like char foo[0x30], to match what's shown. It's acceptable, just annoying to do manually when tools like Ghidra have had automatic buffer length detection for ages.

Additional Information:

Image

An example is the highlighted lines, the buffer is clearly next to a malloc with a static size, and it's used in the strlen function as well, I don't really expect for the type to be filled in. But it should at least be pre filled as an array of 0x30 items, although in Ghidra, this is shown as a char foo[0x30] from the beginning.

Please add any other context or screenshots that would help us understand your feature request here.

@xusheng6
Copy link
Member

Related to #2570 -- but I would say this particular case is simpler that #2570, but it is also quite often seen in actual RE process. So maybe we can solve a simpler case first before we dive into the more complex one?

@xusheng6 xusheng6 added Component: Core Issue needs changes to the core Effort: Medium Issue should take < 1 month Impact: Medium Issue is impactful with a bad, or no, workaround labels Feb 11, 2025
@plafosse
Copy link
Member

As #2570 is currently being worked on I'm going to close this issue in favor of that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Issue needs changes to the core Effort: Medium Issue should take < 1 month Impact: Medium Issue is impactful with a bad, or no, workaround
Projects
None yet
Development

No branches or pull requests

3 participants