Page MenuHomeFreeBSD

ee: Improve handling of malformed UTF-8 characters
ClosedPublic

Authored by markj on Jul 1 2026, 4:46 PM.
Tags
None
Referenced Files
F176182526: D57996.id181347.diff
Fri, Oct 16, 6:26 PM
F176163560: D57996.id181185.diff
Fri, Oct 16, 2:38 PM
Unknown Object (File)
Tue, Oct 13, 1:15 AM
Unknown Object (File)
Mon, Oct 12, 3:02 AM
Unknown Object (File)
Sat, Oct 10, 12:50 PM
Unknown Object (File)
Sat, Oct 10, 10:29 AM
Unknown Object (File)
Fri, Oct 9, 1:16 AM
Unknown Object (File)
Wed, Oct 7, 9:31 PM
Subscribers

Details

Summary

In delete(), when copying the deleted character to the d_char buffer,
don't assume that it fits. utf8_prev() may return a sequence of more
than 5 bytes.

In insert_utf8(), fix the copy-up of the line. We extended the line by
"len" bytes, so "temp" has to be repositioned accordingly. Compare with
plain insert().

Use sizeof when copying to buffers instead of hard-coding buffer sizes.

Don't dynamically allocate d_char, there is no need.

Fixes: 62fba0054d9e ("ee: add unicode support")
Reported by: Sayono Hiragi (overflow in delete())

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable