-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make String#[] not read out-of-bounds if string ends in unicode char (#…
…5257) * Char::Reader: Fail if multi-byte UTF-8 sequence is cut off prematurely Before this change, Char::Reader#decode_char_at() wouldn't detect that an UTF-8 sequence was cut off prematurely. Instead, it continued on reading, leading to an out-of-bounds read. This fix should be regarded as band-aid for Char::Reader. * String#[]: Detect out-of-bounds when ending in a UTF-8 character As Char::Reader signals the end of a string by returning a NUL-char, we need to check in String#[] if the read could go out of bounds. This only triggers if the first byte of the character would be OOB already, which is fine. If a later byte in the character sequence is missing, Char::Reader would notice it.
- Loading branch information
1 parent
a2e8300
commit f6a1fa1
Showing
4 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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