fix(libc): reject oversized snprintf buffers on Windows #5070
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5070"
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 MarcZX10 on 2026-10-13T10:31:40Z.
What
Carries Hussein Kadhim's two original commits for #3974, preserving his author attribution. On Windows,
snprintfandvsnprintfnow return -1 withEOVERFLOWand clear a non-null destination when the buffer size exceedsINT_MAX + 1; the exactINT_MAX + 1boundary still works. Adds regression coverage for oversized sizes,SIZE_MAX, null buffers, and the boundary. A separate MarcZX100 test commit keeps these cases away from the test hunk changed by #4995.Tested
guest_formatting_tests;ctest -R '^guest_formatting$'passed (1/1). Linux excludes the Windows-only size checks.Formatting.cppandtests/Formatting.cpp. A full Windows build could not run: this host's MinGW selects SjLj exceptions, while AnyPS5 requires the WinLibs DWARF toolchain.a11c8f7f). That report is from the issue, not a run of this current-main rebase.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed. No title run was performed.Checklist
main; no open PR implements the same size-limit behaviorNotImplemented_nid_no_patch); no new stubs addeddocs/dev/debt/libc.md; the author confirmed the order works; rebase again after #4981 merges)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T11:13:16Z.
Review note (static): the check matches FreeBSD 11.4
vsnprintf.c: after the size is reduced by one for the terminator,n > INT_MAXsetsEOVERFLOW, writes*str = 0and returnsEOF, andn == 0is not an error, which is whatsize - 1 > INT_MAXwith thesize == 0early return does. Two open points: (1) the Windows blockCheckWindowsSizeLimitshas not been run on Windows by the author (the description says only a syntax-only MinGW check and a Linux run, and the Windows report is from the original base); we can runguest_formattingon Windows 10 with the current head if that helps. (2) The description says the branch conflicts with #4981 indocs/dev/debt/libc.md; whichever lands second needs that rebase.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by likecrank-dotcom on 2026-10-13T14:03:27Z.
Independent Windows verification of current PR head
b7ea2faa78a0eaeddf7853ef6cba50ea5cde8d28, based onmaine152ba8f6962ecab1d00a242d04b3407ebc5f59c(Windows 11 Pro, WinLibs MinGW GCC 15.2.0, CMake 4.4.4):guest_formatting_testsandlibc.prxsuccessfully.ctest --test-dir D:\anyps5_work\build-pr5070-review --output-on-failure -R '^guest_formatting$' --repeat until-fail:5 --timeout 30passed 5/5.tools/check_conventions.py --base origin/main --head HEADandgit diff --check origin/main...HEADpassed.This was a focused target build only. I did not run the baseline regression or launch a title. No changes were made to the PR branch.
AI-assisted verification: OpenAI Codex. The PR author remains responsible for the submitted implementation.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T19:24:19Z.
Thanks for the independent Windows run on predecessor head
b7ea2faa. The current rebased PR head isb6c537b; it has the same Windows size-limit behavior and adds no code beyond the API/conflict adaptation and separated regression hunk, but the exact five-run Windows result is therefore supporting evidence from the prior head, not a current-head validation. I reran MinGW GCC 12 syntax-only checks for the implementation and test source on this head; a full Windows toolchain build is unavailable on my Linux host. If you can rerunguest_formattingonb6c537b, that would close the remaining validation gap. I also rebased this branch on current main; it now depends on #4981 for merge ordering and will need a final rebase if #4981 merges first.Imported from boykopovar/AnyPS5. Originally posted by likecrank-dotcom on 2026-10-13T19:29:07Z.
Follow-up Windows validation by OpenAI Codex (AI-assisted; report authored by an AI), in response to MarcZX100's request:
b6c537b336dd8eb3b293c117337f1d3674f60b15(not the earlierb7ea2faahead).guest_formatting_testson Windows 11 Pro (WinLibs GCC 15.2.0, Ninja, CMake/CTest 4.4.4).guest_formattingpassed five consecutive runs (5/5; 1.17 seconds total).tools/check_conventions.pyandgit diff --checkpassed.No PR code changes were made. The requested current-head Windows validation gap is now covered.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T01:07:13Z.
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release,
-j4: headb6c537b33of this PR merged ontomaind7bb2fee3(clean merge, 3 files).guest_formattingpasses (0.15 s, ctest).core/libs/prx/libc/src/Formatting.cpptaken back tomainand the PR's new test lines kept,guest_formattingfails (unhandled exception St13runtime_error,what(): Formatting check failed, exit code0xc0000409).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T05:20:04Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libc.mdL57-58Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-14T05:21:32Z.
Rebase handoff — rebased onto current
main(all three commits, applies cleanly now), authorship unchanged.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesmainregression (agc_driver_tessellationsegfault, #4727)To pick it up:
Head is
c16404a5c.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:55:29Z.
Closing for now: this matches FreeBSD more closely, but no title on the list needs it yet, and with the queue this long we're only taking changes a named game needs. Reopen with the title ID and the log line it fails on, and it can go back in.
Pull request closed