HomeFreeBSD

lib/libc/amd64/string/strcspn.S: always return earliest match in 17--32 char…

Description

lib/libc/amd64/string/strcspn.S: always return earliest match in 17--32 char case

When matching against a set of 17--32 characters, strcspn() uses two
invocations of PCMPISTRI to match against the first 16 characters
of the set and then the remaining characters. If a match was found in
the first half of the set, the code originally immediately returned
that match. However, it is possible for a match in the second half of
the set to occur earlier in the vector, leading to that match being
overlooked.

Fix the code by checking if there is a match in the second half of the
set and taking the earlier of the two matches.

The correctness of the function has been verified with extended unit
tests and test runs against the glibc test suite.

Approved by: mjg (implicit, via IRC)
MFC after: 1 week
MFC to: stable/14

Details

Provenance
fuzAuthored on Dec 19 2023, 5:28 PM
Parents
rGa0ecf2224ea3: lib/libc/tests/string/strcspn_test.c: add test for correct match order
Branches
Unknown
Tags
Unknown