Vector35 / binaryninja-api

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

Comments within nested code branches split across multiple lines in linear / pseudo C view. #5804

Open 0xPerseus opened 1 month ago

0xPerseus commented 1 month ago

Version and Platform (required):

Bug Description: In the Linear and Pseudo C views, comments within long nested code branches are incorrectly split across multiple lines. This issue causes comments to appear fragmented, as seen in the attached image posted below. The comments are displayed properly in the Graph view (right column), but not in the main Linear / Pseudo C view. This issue does not seem to be present earlier on in the function and will progressively worsen the more nested the logic is.

For example, the comment below should appear as a single contiguous comment, but instead, it is broken into multiple lines.

// Decoded String: "HTTP
// Debugger Windows
// Service (32
// bit).exe"

Steps To Reproduce: Please provide all steps required to reproduce the behavior: 1) Open a code file and create a comment within a long nested code branch 2) View the code within Linear / Pseudo C mode. 3) Observe how the comments are split across multiple lines.

Expected Behavior: The comment should appear as a single line, like this:

// Decoded String: "HTTP Debugger Windows Service (32 bit).exe"

Screenshots/Video Recording: Screenshot of the issue provided below.

binaryninja_EPiPzYfWKY

Additional Information: These comments are auto-generated using a custom Binary Ninja plugin I've written to aid in the analysis of this piece of malware that leverages the "self.bv.set_comment_at" function for a provided address. Although I'm not confident that this is related to the bug, I figured it was worth mentioning just in case.

xusheng6 commented 1 month ago

We have a ui.view.common.commentWidth that decides when to wrap the comment. It defaults to 80, do you have a custom value for it?

Also, if you add the comment from within the UI, does it look the same?

I tried to reproduce this, but the comment is wrapped at the proper length. Would it be possible to share with us the binary to allow us to reproduce it?