mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 02:03:35 +08:00
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>
This commit is contained in:
parent
f566b02852
commit
e5672763c4
@ -52,6 +52,10 @@
|
||||
|
||||
.section SECTION(.text), "ax", @progbits
|
||||
ENTRY(STRNCPY)
|
||||
# ifdef __ILP32__
|
||||
/* Clear the upper 32 bits. */
|
||||
movl %edx, %edx
|
||||
# endif
|
||||
/* Filter zero length strings and very long strings. Zero
|
||||
length strings just return, very long strings are handled by
|
||||
just running rep stos{b|l} to zero set (which will almost
|
||||
|
@ -80,6 +80,10 @@
|
||||
|
||||
.section SECTION(.text), "ax", @progbits
|
||||
ENTRY(STRNCPY)
|
||||
# ifdef __ILP32__
|
||||
/* Clear the upper 32 bits. */
|
||||
movl %edx, %edx
|
||||
# endif
|
||||
/* Filter zero length strings and very long strings. Zero
|
||||
length strings just return, very long strings are handled by
|
||||
just running rep stos{b|l} to zero set (which will almost
|
||||
|
Loading…
Reference in New Issue
Block a user