Page MenuHomeFreeBSD

libc: locale: fix EUC shift check
ClosedPublic

Authored by kevans on Dec 31 2023, 11:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 24, 9:56 PM
Unknown Object (File)
Sun, Apr 20, 8:22 PM
Unknown Object (File)
Sat, Apr 19, 9:23 PM
Unknown Object (File)
Sat, Apr 19, 8:55 PM
Unknown Object (File)
Sat, Apr 19, 7:57 PM
Unknown Object (File)
Sat, Apr 19, 7:54 PM
Unknown Object (File)
Sat, Apr 19, 7:06 PM
Unknown Object (File)
Sat, Apr 19, 3:31 AM
Subscribers

Details

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 Not Applicable
Unit
Tests Not Applicable

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
This revision was automatically updated to reflect the committed changes.