Skip to content

Handle SStream overflow by truncating appends#2909

Closed
trufae wants to merge 4 commits into
capstone-engine:nextfrom
trufae:remaining
Closed

Handle SStream overflow by truncating appends#2909
trufae wants to merge 4 commits into
capstone-engine:nextfrom
trufae:remaining

Conversation

@trufae
Copy link
Copy Markdown
Contributor

@trufae trufae commented Apr 30, 2026

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

This enforces null terminated buffer and behaves better as it truncates properly in case there's not enough space. im fine for not merging this but i prefer a consistent behaviour than an assert with a macro. but thats just up to decide the behaviour users expects from this corner case
...

Test plan

there's a test attached
...

Closing issues

...

@github-actions github-actions Bot added the CS-core-files auto-sync label Apr 30, 2026
Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure way cleaner! Thanks.
One nitpick, otherwise lgtm.

Comment thread SStream.c
Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
Comment thread SStream.c Outdated
if (remaining == 0) {
return;
}
CS_ASSERT_RET(remaining > 0)
Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 May 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;.

(Can make a suggestion. Github is broken again for whatever reason.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread SStream.c Outdated
Comment thread SStream.c Outdated
@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented May 11, 2026

@trufae Can you please run clang-format real quick. Otherwise lgtm and I would merge.

@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented May 12, 2026

Cherry-picked your changes here: #2921

Thanks a lot!

@Rot127 Rot127 closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CS-core-files auto-sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants