]> git.ipfire.org Git - thirdparty/glibc.git/commit
wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 19 Mar 2024 13:15:28 +0000 (10:15 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 11 Apr 2024 17:21:32 +0000 (14:21 -0300)
commitcf11e74b0d81d389bcad5cdbba020ba475f0ac4b
tree625ec5b8d30d0d6b3de93daebebcda688007c1e8
parent4b717562c4768883a87f62d67610c0a48e911445
wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865)

It uses the same two-way algorithm used on strstr, strcasestr, and
memmem.  Different than strstr, neither the "shift table" optimization
nor the self-adapting filtering check is used because it would result in
a too-large shift table (and it also simplifies the implementation bit).

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
string/test-strstr.c
wcsmbs/wcs-two-way.h [new file with mode: 0644]
wcsmbs/wcsstr.c