diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2022-09-20 17:58:04 -0700 |
---|---|---|
committer | Sunil K Pandey <skpgkp2@gmail.com> | 2022-11-24 16:28:58 -0800 |
commit | 0a888ff9bd83bbad572e6cdf188006408b9aa9b1 (patch) | |
tree | 0a51fec4dc5e20417193d959e9117114f43f41c6 /sysdeps | |
parent | 0c9137a4449789649eb42b3f1b7cfdff4968ff2b (diff) | |
download | glibc-0a888ff9bd83bbad572e6cdf188006408b9aa9b1.zip glibc-0a888ff9bd83bbad572e6cdf188006408b9aa9b1.tar.gz glibc-0a888ff9bd83bbad572e6cdf188006408b9aa9b1.tar.bz2 |
x86: Fix wcsnlen-avx2 page cross length comparison [BZ #29591]
Previous implementation was adjusting length (rsi) to match
bytes (eax), but since there is no bound to length this can cause
overflow.
Fix is to just convert the byte-count (eax) to length by dividing by
sizeof (wchar_t) before the comparison.
Full check passes on x86-64 and build succeeds w/ and w/o multiarch.
(cherry picked from commit b0969fa53a28b4ab2159806bf6c99a98999502ee)
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/x86_64/multiarch/strlen-avx2.S | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/sysdeps/x86_64/multiarch/strlen-avx2.S b/sysdeps/x86_64/multiarch/strlen-avx2.S index 45e08e6..8cfb739 100644 --- a/sysdeps/x86_64/multiarch/strlen-avx2.S +++ b/sysdeps/x86_64/multiarch/strlen-avx2.S @@ -542,14 +542,11 @@ L(return_vzeroupper): L(cross_page_less_vec): tzcntl %eax, %eax # ifdef USE_AS_WCSLEN - /* NB: Multiply length by 4 to get byte count. */ - sall $2, %esi + /* NB: Divide by 4 to convert from byte-count to length. */ + shrl $2, %eax # endif cmpq %rax, %rsi cmovb %esi, %eax -# ifdef USE_AS_WCSLEN - shrl $2, %eax -# endif VZEROUPPER_RETURN # endif |