fix(libc): ignore non-wide lengths on character scans #13049
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13049"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-29T23:40:49Z.
What
A character field such as
%llsin the title-bundled libc modules stores narrow bytes. Forwarding it to glibc can instead store 32-bit wide characters. The same discrepancy affects ignored length tokens on%cand%[fields.Normalize accepted non-wide lengths in host-backed character scans and in the secure scanner's generated directives. Preserve a single
l, numeric lengths, widths/suppression, literal%%and scanset members. Regression cases check consumed bytes and destination guards through ordinary, secure and va-list string/file APIs.Related work: #12428 supplies the Windows ordinary-parser length rule; #12468 supplies wide-field recognition/decoding. This implementation complements those paths. The new Windows cases exercise the secure paths changed here; the new Linux cases exercise all eight entry points.
Tested
Linux x86-64 Release, exact production/test source
ce32d855ba3817332ab44e454f95f6257836943d, based on main7a225bb303c1a452057000f32b70b56486625fd6. Clean merge preview against subsequently fetched main1189ec3003672bb364dd9f3119ead7b3976e3c83; public branches of related PRs were preserved.guest_formatting_testsandfile_streams_testsexecutables fail against coherent unmodified base libraries with the expected character-scan length failures. Restored candidate library bytes match the module used for reference comparison.sscanf/sscanf_sfscanf/fscanf_s700 full rows corrected; zero regressions in previously correct observed fields. Twenty further destination-prefix fields become correct while an existing short-field return mismatch remains. Existing EOF errno, wide/uppercase-conversion and short-character gaps remain explicit. The short-character gap is recorded in debt. This is not complete scanf coverage.
Authored probes, synthetic reference/main/change rows, positive/negative logs, source pins and hashes, SHA-256
7fceb0465f933407de4eab5d866804a957185ac902f1c8d32c483894d30cf233(download verified). No SDK binaries, game assets, saves or screenshots are included.Conventions/whitespace pass. Required overlap scan checked 1431 open PRs with no automatic positive overlap. Shared-file diffs of peers already conflicting with main were reviewed; their classifications are attached. No blanket peer-mergeability claim.
Windows/macOS execution is not locally qualified. Windows ordinary scans use the separate parser covered by #12428; this PR's Windows regression cases cover its four secure entry points. No console, title, graphics, audio or FPS claim.
Independent Windows validation, reported by bunbeans2-arch for topic
ce32d855ba3817332ab44e454f95f6257836943dagainst mainf7f03daf52: Windows 11 Pro 22631, i9-9900K, MSYS2 UCRT64 GCC 16.1, Release.file_streamsandguest_formattingpass 5/5; keeping the new tests while restoringFormatting.cppto main makes both fail 5/5; plain main passes 3/3. This is the contributor's run, not a new local Windows execution.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T00:09:09Z.
Review: APPROVED
Reviewed — looks good
The change normalizes ignored narrow-character scan lengths while preserving the single-
lwide path, with regression coverage across string, stream, secure, and va-list entry points.What I ran
Reviewed exact head
ce32d855ba3817332ab44e454f95f6257836943dagainst currentmaine7d8e353362935a1f00e893d901b1debc671f5ce; the clean merge-preview tree is6715ec4f2bcc30b5f5733ddbe0aa744f15f1fed1. Environment: Debian Linux x86-64, Python 3.11.2; no compiler or build was run.Not verified
I did not build or run the C++ tests locally, and I did not verify physical-console or game behavior. Some hosted platform matrix jobs were still running or queued at review time.