Page MenuHomeFreeBSD

libc: locale: fix EUC shift check
AcceptedPublic

Authored by kevans on Dec 31 2023, 11:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 9, 10:45 PM
Unknown Object (File)
Thu, May 9, 6:18 PM
Unknown Object (File)
Mon, Apr 22, 12:47 PM
Unknown Object (File)
Apr 6 2024, 8:16 PM
Unknown Object (File)
Mar 14 2024, 5:40 PM
Unknown Object (File)
Feb 9 2024, 12:49 PM
Unknown Object (File)
Jan 18 2024, 3:19 PM
Unknown Object (File)
Jan 11 2024, 11:32 PM
Subscribers

Details

Reviewers
yuripv
bapt
rew
Group Reviewers
Klara
Summary

wchar_t is unsigned on ARM platforms, and signed pretty much everywhere
else. On signed platforms, nm ends up with bogus upper bits set if we
did in-fact have a valid CS2 or CS3 (MSB set). Mask just the low byte
to avoid sign bit garbage.

Bare basic test of converting a CS2 widechar in eucCN, which would
previously kick back an EILSEQ.

Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 55183
Build 52072: arc lint + arc unit

Event Timeline

rew added inline comments.
lib/libc/locale/euc.c
429

I noticed a few lines up where wc is cast to an unsigned when determining the length..

would that suffice here as well? if it did work, it would be consistent with how wc is handled elsewhere in this function.

lib/libc/locale/euc.c
429

Sure- that was my first iteration, but it felt marginally cleaner to treat it like we do in the loop down below where we're just masking a single byte (for different, but at the same time the exact same, reasons).

This revision is now accepted and ready to land.Jan 1 2024, 9:16 PM