feat(libc): implement binary-safe memmem #2058
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2058"
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 QRMOE on 2026-10-09T06:09:25Z.
What
Adds
memmem(AyXlXD4Y3n8) using bounded binary search. Returns the first match, handles embedded NUL bytes, returns the haystack for an empty needle, and rejects a needle longer than the haystack without reading it. No heap allocation or guest errno changes. Reference: FreeBSD memmem.Tested
guest_memmempasses: 5,000 generated cases checked against an independent binary string-search oracle, explicit repeated-prefix and NUL/high-bit inputs, and both buffers positioned immediately before inaccessible pages over multiple lengths.Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT/posix/SEH, Ninja Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON; basef145139676a48306681d3a4d5fabf83938759daf.Combined validation of these three independent branches: full
libstarget built successfully, including NID patching;guest_memmem,guest_bcopy, both line-input tests,guest_standard_streams, andguest_errorspass (6/6). All four NIDs are present in patchedlibc.prx. Conventions, diff whitespace and test registration checks pass. The branches were also built and tested individually before integration.Before publication, actual library diffs of 559 candidate PR heads were checked for these names and NIDs, including broad PRs and newer heads; no other implementation of these four exports was found. The candidates cover the cached open-PR list and every newer PR head; some candidates may have closed since that list was read.
Linux, console behavior, games and the complete CTest suite have not been run. This adds documented libc interfaces; no particular title starting successfully is claimed.
Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:11:00Z.
Review: APPROVED
Reviewed the full diff against the FreeBSD memmem contract. The implementation handles the zero-length needle and too-short haystack before forming/dereferencing ranges, searches bytes (including embedded NULs), and returns the first match. The randomized binary oracle and guard-page cases are useful boundary coverage. I built and ran the exact head on Linux with GCC 12; guest_memmem passed (1/1, 0.02 s). Conventions and diff checks pass. The PR reports Windows builds and tests; upstream currently has no check results for this fork head.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:55:59Z.
Closing: no title is shown to reach
memmemon main, and library functions go in when one does. Please reopen with the title ID and the log line where it stops if you find one.Pull request closed