You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[crash] text-freetype2: UTF-16 file stored as wchar_t* without wide NUL → OOB read+write (Linux/macOS) #95
— a raw UTF-16 (2-byte-unit) buffer into srcdata->text, which is wchar_t *. On Linux/macOS wchar_t is 4 bytes and the buffer ends with only two zero bytes — no wide-NUL terminator.
remove_cr (:359-367) then runs for (i; source[i] != L'\0'; ++i) reading 4-byte wchar_ts and source[j] = L'\0' writes 4 bytes at the scan length — both range past the allocation whenever the file lacks a 4-aligned U+0000. wcslen calls in cache_glyphs (:283), set_up_vertex_buffer (:63) and fill_vertex_buffer (:143) do the same OOB scan. read_from_end stores UTF-16 the same way (:475-481).
Bonus defect in read_from_end (:452-471): cur_pos is uint32_t; for a UTF-16 file whose size leaves cur_pos odd (e.g. 2-byte BOM + 1 byte), cur_pos -= 2 underflows to 0xFFFFFFFF and the loop spins through ~2³¹ fseek/fread calls → hang.
Fix sketch: decode UTF-16 to UTF-8 and go through os_utf8_to_wcs_ptr (or store UTF-32); clamp the backwards scan to cur_pos >= 2.
Working on this: decoding UTF-16 files into wchar_t properly on 4-byte-wchar_t platforms, bounding the backwards scan in read_from_end, plus a cmocka test. PR to follow.
Activity
b7216309-jpg commentedon Oct 10, 2026
Working on this: decoding UTF-16 files into wchar_t properly on 4-byte-wchar_t platforms, bounding the backwards scan in read_from_end, plus a cmocka test. PR to follow.
text-freetype2: Decode UTF-16 through UTF-8 and bound tail scan
text-freetype2: Move the text file readers to text-file.c
test/cmocka: Add text-freetype2 text file test
text-freetype2: Decode UTF-16 text files into wide strings
text-freetype2: Move the text file readers to text-file.c
test/cmocka: Add text-freetype2 text file test
text-freetype2: Decode UTF-16 text files into wide strings
text-freetype2: Decode UTF-16 through UTF-8 and bound tail scan