x86-64 strncpy: Properly handle the length parameter [BZ# 29839]
commite5672763c44f16ddbc42809f5def7c6a962602bd
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 2 Dec 2022 00:36:02 +0000 (1 16:36 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 2 Dec 2022 16:18:41 +0000 (2 08:18 -0800)
treea34a3791fc27a9402cb0f78c611e8d5de568c316
parentf566b028524149ddfebe7f9770a3befb13b81a13
x86-64 strncpy: Properly handle the length parameter [BZ# 29839]

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 strncpy 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/strncpy-avx2.S
sysdeps/x86_64/multiarch/strncpy-evex.S