fix(libc): report fopen_s and freopen_s argument errors to the constraint handler #12597
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12597"
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-28T22:17:22Z.
What
fopen_sandfreopen_snow report argument errors to the constraint handler, as titles'libc.prxdoes. The handler getsEINVALand a null pointer, with these messages:FILE **"fopen_s: bad FILE ** argument"fopen_s), null mode, or null stream (freopen_s)"fopen_s: bad argument"freopen_sreally does report thefopen_smessages. Onmainboth returnedEINVALwithout calling the handler. The return values and the stored stream (left alone for a nullFILE **, set to null otherwise) were already right and are unchanged. Other errors, such as an invalid mode or a missing file, are not changed here.Depends on #9935. On
mainthe default constraint handler aborts, so until #9935 merges, a title that hits one of these violations without installing a handler would abort. Merges cleanly with #9935, #10755 and #11831.Tested
Windows 11, WinLibs GCC 15.2.0 UCRT r7, Release,
main319621ba2e.fopen_sandfreopen_s(including all null), plusgets_swith size 0, size2^61and a null buffer. Each case compares the return value, the stored stream, and the handler's calls, error, pointer and message.main: the 9fopen_s/freopen_scases differ, and the 3gets_scases already match.guest_fiopenandguest_fopen_errorsinstall a recording handler around these cases and check each message. With the previousFileAndHeap.cppboth fail.guest_fiopen,guest_fopen_errors,guest_safe_errors,guest_bounds_checkingandguest_crtpass 3/3. Conventions pass.Current qualification — 2026-10-30
Integrated upstream main
08a10d225306ad102b57408e2ef7566bcfb829b2at1768c1821b2921745f051fb97b999bb63b97f38f, retaining the actual previous head and main as parents. Manual conflict resolution changes only debt documentation; production and test files equal the automatic merge output. Both parents' added test lines and main gitlinks are preserved.Linux CPU: 9 passes (guest_fiopen, guest_fopen_errors, guest_crt); public_headers 1 passes; no skips. MinGW source syntax and conventions pass.
No new Windows/macOS runtime, native SDK, game, GPU or performance claim. The Windows user pause remains in force.
Evidence: immutable source and qualification receipts, SHA-256
61f5500e7526ea4e107159927de78c37db7e0ac1cb7ebd8625b22ab0ad5d9bd7(download verified).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)