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
F170629804: D57996.diff
Sat, Sep 5, 5:32 PM
F170477964: D57996.id181185.diff
Sat, Sep 5, 12:31 AM
F170444936: D57996.diff
Fri, Sep 4, 8:56 PM
Unknown Object (File)
Fri, Sep 4, 9:16 AM
Unknown Object (File)
Fri, Sep 4, 4:18 AM
Unknown Object (File)
Fri, Sep 4, 2:27 AM
Unknown Object (File)
Thu, Sep 3, 5:17 PM
Unknown Object (File)
Thu, Sep 3, 8:03 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 74465
Build 71348: arc lint + arc unit