Page MenuHomeFreeBSD

libc: locale: fix some assumptions that wchar_t cannot be signed
Needs ReviewPublic

Authored by kevans on Jun 7 2025, 2:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 14 2025, 4:39 PM
Unknown Object (File)
Aug 26 2025, 6:35 AM
Unknown Object (File)
Aug 15 2025, 3:09 PM
Unknown Object (File)
Aug 14 2025, 1:45 AM
Unknown Object (File)
Jul 8 2025, 8:43 PM
Unknown Object (File)
Jul 8 2025, 1:39 PM
Unknown Object (File)
Jul 6 2025, 3:07 PM
Unknown Object (File)
Jul 5 2025, 10:50 AM
Subscribers

Details

Reviewers
markj
bapt
Summary

wchar_t signedness is platform-dependant, and it's actually signed on
powerpc, riscv and x86. We make some assumptions in Libc that they
aren't negative, which could lead to some invalid accesses.

Ensure that comparisons for <= UCHAR_MAX also confirm that the value is
positive, and in largesearch() let's cast it to an unsigned value in
case we actually do have a character mapped but it's just unfortunately
out of range for our signed wchar_t. We still have a chance of doing
the right thing.

Sponsored by: Klara, Inc.

Diff Detail

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