Treat a zero *nelp as a miss before validating key, base, compare or
size, matching bsearch so a lookup against a not-yet-allocated table
(base null, count zero) returns null instead of throwing. Cover it with
a GuestSearch case that exercises null base with zero count and zero
comparator calls.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
AGENTS.md allows only #endif and namespace-end comments. Drop the
explanatory lines added alongside the new lfind/lsearch exports and
their guest_search coverage, and tighten the debt entry below the
1000-character limit flagged by tools/check_conventions.py.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
Add FreeBSD/POSIX lfind and lsearch for the libc PRX, with explicit
guards against null arguments, zero element size, and span arithmetic
that would overflow size_t. lsearch validates the existing search
range before any comparator call, then separately checks the append
capacity so a matched element never requires room for an extra one.
Extend guest_search to cover first-match on duplicate keys, zero-count
no-op, byte-exact appended payload, zero-count seed, and that the
overflow guard fires without touching element memory or invoking the
callback. Document the exports in docs/dev/debt/libc.md.
Co-Authored-By: Claude Opus 4.7 <[email protected]>