HomeFreeBSD

ee: Improve handling of malformed UTF-8 characters

Description

ee: Improve handling of malformed UTF-8 characters

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())
Reviewed by: bapt
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57996

Details

Provenance
markjAuthored on Jul 6 2026, 1:16 PM
Reviewer
bapt
Differential Revision
D57996: ee: Improve handling of malformed UTF-8 characters
Parents
rG38dd686b9336: jaildesc: Publish the new fd only after the jaildesc is initialized
Branches
Unknown
Tags
Unknown