Skip to content

Fix heap out-of-bounds reads in UTF8Util (issues #794 and #799)#1098

Merged
frankslin merged 5 commits intomasterfrom
copilot/fix-heap-out-of-bound-read
Apr 14, 2026
Merged

Fix heap out-of-bounds reads in UTF8Util (issues #794 and #799)#1098
frankslin merged 5 commits intomasterfrom
copilot/fix-heap-out-of-bound-read

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

  • Fix heap OOB reads in UTF8Util.hpp (issues Heap Out-Of-Bound Read in UTF8Util.hpp #794 and Stack buffer overflow in UTF8Util.hpp #799) — PrevCharLength reorder
  • Workaround MSVC LTCG ICE: simplify control flow (while loop, no nested for-with-return)
  • Revert silent-truncation behaviour per reviewer feedback:
    • Length(): throws InvalidUTF8 on truncated sequence — still avoids reading past \0 (uses while loop, MSVC-safe)
    • UTF8StringSliceBase(const char*): reverted to simple UTF8Util::Length() + strlen() one-liner
    • LengthTruncatedSequence test: EXPECT_EQ(0, ...)EXPECT_THROW(..., InvalidUTF8)
    • All 17 tests pass

Copilot AI linked an issue Apr 13, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 14, 2026 00:11
Copilot AI changed the title [WIP] Fix heap out-of-bound read in UTF8Util.hpp Fix heap out-of-bounds reads in UTF8Util (issues #794 and #799) Apr 14, 2026
Copilot AI requested a review from frankslin April 14, 2026 00:17
@frankslin frankslin marked this pull request as ready for review April 14, 2026 00:24
…tringSliceBase ctor

Agent-Logs-Url: https://github.com/BYVoid/OpenCC/sessions/c3e68446-b39f-4c0f-9013-2a3cc42c35d0

Co-authored-by: frankslin <748873+frankslin@users.noreply.github.com>
…iceBase simplification

Agent-Logs-Url: https://github.com/BYVoid/OpenCC/sessions/6588ec72-bb39-41f7-a952-29f7ad8c1ae4

Co-authored-by: frankslin <748873+frankslin@users.noreply.github.com>
@frankslin frankslin merged commit 469a1b5 into master Apr 14, 2026
33 checks passed
@BYVoid BYVoid deleted the copilot/fix-heap-out-of-bound-read branch April 14, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Heap Out-Of-Bound Read in UTF8Util.hpp

3 participants