HomeFreeBSD

lib/libc/amd64/string/memchr.S: fix behaviour with overly long buffers

Description

lib/libc/amd64/string/memchr.S: fix behaviour with overly long buffers

When memchr(buf, c, len) is called with a phony len (say, SIZE_MAX),
buf + len overflows and we have buf + len < buf. This confuses the
implementation and makes it return incorrect results. Neverthless we
must support this case as memchr() is guaranteed to work even with
phony buffer lengths, as long as a match is found before the buffer
actually ends.

Sponsored by: The FreeBSD Foundation
Reported by: yuri, des
Tested by: des
Approved by: mjg (blanket, via IRC)
MFC after: 1 week
MFC to: stable/14
PR: 273652

Details

Provenance
fuzAuthored on Sep 10 2023, 4:11 AM
Parents
rG4fc08109fe32: Correct the grammo in "will underlined".
Branches
Unknown
Tags
Unknown