Repository navigation
fix(libc): reject oversized secure copy destinations - #4455
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
Conversation
10 tasks done
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
memcpy_sandmemmove_scurrently accept destination sizes aboveRSIZE_MAX. A call with a small count can incorrectly succeed; if the source is null or the count exceeds the destination size, the error path passes the oversized length tomemset, potentially writing beyond the destination before returning an error.Reject oversized destination sizes before copying or clearing. Use
SIZE_MAX >> 1, matching the existingmemset_slimit, and return the existing guestERANGEvalue (34). Valid destination sizes retain their existing behavior: a constraint violation clears only the declared destination, andmemmove_sstill supports overlap.The no-write rule follows C11 N1570, K.3.7.1.1 paragraphs 2–3 and K.3.7.1.2 paragraphs 2–3. Annex K requires a nonzero error, without prescribing its numeric value. The console's exact limit/error and the existing omission of constraint-handler invocation are recorded in TechnicalDebt.
This addresses the separate
memcpy_s/memmove_sgap Fishybeing noted in #3166; that issue'smemset_sfix already merged as #3280. This implementation and its regression tests are new.Adds behavioral regression coverage for both functions: destination sizes
RSIZE_MAX + 1andSIZE_MAX, zero/small/oversized counts, null and non-null sources, the acceptedRSIZE_MAXboundary, and guard bytes around a valid destination cleared on error. The new test fails against unchangedmainand passes with the fix.This fixes functions already counted as implemented; it does not increase the system-library progress percentage. No title-specific unblock is claimed.
Tested
Windows 11 Pro, WinLibs MinGW-w64 GCC 15.2.0 (
15.2.0posix-14.0.0-ucrt-r7), Release,BUILD_TESTING=ON.cmake --build build --parallel 6passed.cmake --build build --target libs --parallel 6passed.guest_strings,guest_wide_strings,guest_math,guest_memory,guest_memory_pool_stats,patched_libraries,conventions_function_bodies, andtest_registration. The newguest_stringscase runs in about 0.01–0.04 seconds on this host.guest_string_testswith unchangedorigin/main'sStrings.cpp, keeping the new tests;guest_stringsfailed. Restoring the fix and rebuilding made it pass.python tools/check_conventions.py --base origin/mainandgit diff origin/main --checkpassed.python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch fix/libc-secure-copy-size-limitsreported no overlap with open PRs.Base:
ffa198407e70296c50d0011a4157a430408dd00e. The complete CTest suite was not run. Linux and console/title testing have not been performed; maintainer-triggered full Linux/Windows CI is still required.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository