Repository navigation
text-freetype2: Decode UTF-16 through UTF-8 and bound tail scan - #123
Closed
chriscoveries wants to merge 1 commit into
Closed
chriscoveries wants to merge 1 commit into
chriscoveries wants to merge 1 commit into
Conversation
UTF-16 file bytes were fread straight into a wchar_t buffer: on Linux/macOS wchar_t is 4 bytes, so the bytes never formed a NUL- terminated wide string and remove_cr/wcslen scanned out of bounds. read_from_end could also underflow cur_pos (uint32) below 0 on odd file sizes, wrapping the tail scan into an unbounded loop. - decode UTF-16LE (with surrogate pairs) to UTF-8, then reuse the existing os_utf8_to_wcs path for a proper wchar_t string - clamp the utf16 tail-scan decrement at 0 instead of wrapping - skip the BOM when the scan reaches the start of the file Fixes obs-rust#95 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
|
Heads-up @chriscoveries: b7216309-jpg claimed #95 on the issue at 21:55 ("Working on this… plus a cmocka test. PR to follow") and opened #121 at 22:00 with a RED→GREEN test. This PR, opened at 22:09, covers the same fix without a test. I'm reviewing and landing #121 as the claimed one. If your bounded tail scan differs in a way #121 misses, please comment on #121. Otherwise, could you close this one? Checking the issue for a claim comment before starting avoids the duplicate. |
This was referenced Oct 10, 2026
Contributor
Author
|
Closing ours in favour of #121 by @b7216309-jpg, which is the better fix: it adds tests, handles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UTF-16 file bytes were
freadstraight into awchar_tbuffer: on Linux/macOSwchar_tis 4 bytes, so the data never formed a NUL-terminated wide string andremove_cr/wcslenscanned out of bounds.read_from_endalso underflowedcur_pos(uint32_t) below 0 on odd file sizes, wrapping the tail scan into an unbounded loop.os_utf8_to_wcspath sosrcdata->textis a properwchar_tstring everywhereFixes #95