x86-64 strncat: Properly handle the length parameter [BZ# 24097]
commitf566b028524149ddfebe7f9770a3befb13b81a13
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 2 Dec 2022 00:37:11 +0000 (1 16:37 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 2 Dec 2022 16:18:10 +0000 (2 08:18 -0800)
tree7ddae400809cd9e2902af7fcd59e3bf22597809c
parent6ae0737d430900fff02569548a92bdca49622a15
x86-64 strncat: Properly handle the length parameter [BZ# 24097]

On x32, the size_t parameter may be passed in the lower 32 bits of a
64-bit register with the non-zero upper 32 bits.  The string/memory
functions written in assembly can only use the lower 32 bits of a
64-bit register as length or must clear the upper 32 bits before using
the full 64-bit register for length.

This pach fixes strncat for x32.  Tested on x86-64 and x32.  On x86-64,
libc.so is the same with and without the fix.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
sysdeps/x86_64/multiarch/strcat-sse2-unaligned.S
sysdeps/x86_64/multiarch/strncat-avx2.S
sysdeps/x86_64/multiarch/strncat-evex.S
sysdeps/x86_64/x32/Makefile
sysdeps/x86_64/x32/tst-size_t-strncat.c [new file with mode: 0644]