Skip to content

Fix GH-18901: integer overflow mb_split #18906

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

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jun 22, 2025

We prevent signed overflow by making the count unsigned. The actual interpretation of the count doesn't matter as it's just used to denote a limit.

The test output for some limit values looks strange though, so that may need extra investigation. However, that's orthogonal to this fix.
I.e. I think ((OnigUChar *)(string + beg) - chunk_pos)) needs to be ((OnigUChar *)(string + end) - chunk_pos))
EDIT: Just double checked and it seem alright anyway

We prevent signed overflow by making the count unsigned. The actual
interpretation of the count doesn't matter as it's just used to denote a
limit.

The test output for some limit values looks strange though, so that may
need extra investigation. However, that's orthogonal to this fix.
@nielsdos nielsdos linked an issue Jun 22, 2025 that may be closed by this pull request
Copy link
Contributor

@youkidearitai youkidearitai left a comment

Choose a reason for hiding this comment

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

LGTM

@alexdowad
Copy link
Contributor

Makes sense to me. Thanks for catching this!

@nielsdos nielsdos closed this in a5f21ca Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integer overflow mb_split
3 participants