git: DragonFly_RELEASE_6_4 libc: reject a negative wchar_t in the UTF-8 encoder

Aaron LI aly at crater.dragonflybsd.org
Sun Sep 27 03:16:24 PDT 2026


commit 9ee24a3c31f29b2574825b4fb21d790331dffe39
Author: Showta Ishizaki <zakinko at snowrabbit.org>
Date:   Fri Sep 11 06:54:05 2026 +0900

    libc: reject a negative wchar_t in the UTF-8 encoder
    
    _UTF8_wcrtomb() and _UTF8_wcrtombin() pick the four byte form with
    "wc <= 0x10ffff".  wchar_t is signed, so every negative value passes
    that test and is encoded from its low bits: wcrtomb() of (wchar_t)-1
    returns 4 and writes ff bf bf bf, and printf("%lc", -1) prints those
    bytes instead of failing with EILSEQ as it does for 0x110000.
    
    Add "wc >= 0 &&" to both tests, as FreeBSD's utf8.c has.
    
    GitHub-PR: https://github.com/DragonFlyBSD/DragonFlyBSD/pull/57
    FreeBSD: https://github.com/freebsd/freebsd-src/commit/8bb93485fb51aac423ec000aa292815cf50bb02c

Summary of changes:
 lib/libc/locale/utf8.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/9ee24a3c31f29b2574825b4fb21d790331dffe39


-- 
DragonFly BSD source repository


More information about the Commits mailing list