Repository navigation
fix(libc): safely probe the locale name of setlocale - #20653
Merged
oneandonlydean merged 1 commit intoNov 15, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
setlocalecheckedlocale[0]andstrcmp'd the name with"C"straight through the guest pointer, so a non-null name pointing at unmapped memory faulted the host.It only accepts
""and"C"(and a null name as a query), so it only needs the first two bytes. Those are now read withCopyGuestString_nid_no_patchcapped at 2, the same approach as #20644 for the_Locinfoconstructor:""and"C"come back as themselves and return"C";The null query and every category's results for readable names are unchanged.
The debt entry goes in a fragment under
docs/dev/debt/changes/and records this as unmeasured.Tested
Linux (Ubuntu 26.04.1), GCC 15.2, Release.
guest_character: for categories 0-6,setlocalewith an unmapped name (0x10) returns null. The existing"C","POSIX", null,"","en_US.UTF-8"and out-of-range category cases and the ctype table checks still pass.StdioExtras.cppfrommainand this test,guest_charactersegfaults.git merge-treeagainst the open PRs that touchStdioExtras.cpp(feat(libs): mirror libkernel exports through libkernel_web #18112, fix(prx): keep forwarding exports from binding to themselves on Linux #13730, fix(libc): check sprintf_s and vsprintf_s as titles' libc.prx does #12622): no new conflicts. No open PR touchesGuestCharacter.cpp.tools/check_conventions.pypasses on the branch and this body;tools/debt_fold.py --checkpasses with the fragment applied tomain.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)