Skip to content

Commit

Permalink
libhfs: fix check for invalid unicode surrogates
Browse files Browse the repository at this point in the history
This was a bit too broad and treated certain valid codepoints over
U+DFFF as an error when converting UTF-8 to UTF-16, for example the
Apple logo in the BMP private use area (U+F8FF.)
  • Loading branch information
0x09 committed Apr 23, 2024
1 parent 29499c0 commit c71d645
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libhfs/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ utf8_to_utf16(uint16_t *dst, size_t dst_len,
c = ((s[spos] & 0x0f) << 12) | ((s[spos+1] & 0x3f) << 6)
| (s[spos+2] & 0x3f);
spos += 3;
if (c < 0x800 || (c & 0xdf00) == 0xd800 ) {
if (c < 0x800 || c >= 0xd800 && c <= 0xdfff) {
/* overlong encoding or encoded surrogate */
error++;
continue;
Expand Down

0 comments on commit c71d645

Please sign in to comment.