aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--string/test-strncat.c15
-rw-r--r--sysdeps/i386/i686/multiarch/strcat-sse2.S2
-rw-r--r--sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S2
4 files changed, 29 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8af3a19..1bb6eaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-01-03 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ [BZ #19390]
+ * string/test-strncat.c (test_main): Add tests with SIZE_MAX as
+ maximum string size.
+ * sysdeps/i386/i686/multiarch/strcat-sse2.S (STRCAT): Avoid overflow
+ in pointer addition.
+ * sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S (STRCPY):
+ Likewise.
+
2017-01-03 Joseph Myers <joseph@codesourcery.com>
* elf/Makefile ($(objpfx)tst-ldconfig-X.out): Correct arguments
diff --git a/string/test-strncat.c b/string/test-strncat.c
index 55d6cc5..26a6b5b 100644
--- a/string/test-strncat.c
+++ b/string/test-strncat.c
@@ -284,12 +284,23 @@ test_main (void)
do_test (0, 0, 8, 8, n, SMALL_CHAR);
do_test (0, 8, 8, 8, n, SMALL_CHAR);
+ do_test (0, 2, 2, 2, SIZE_MAX, SMALL_CHAR);
+ do_test (0, 0, 4, 4, SIZE_MAX, SMALL_CHAR);
+ do_test (4, 0, 4, 4, SIZE_MAX, BIG_CHAR);
+ do_test (0, 0, 8, 8, SIZE_MAX, SMALL_CHAR);
+ do_test (0, 8, 8, 8, SIZE_MAX, SMALL_CHAR);
+
for (i = 1; i < 8; ++i)
{
do_test (0, 0, 8 << i, 8 << i, n, SMALL_CHAR);
do_test (8 - i, 2 * i, 8 << i, 8 << i, n, SMALL_CHAR);
do_test (0, 0, 8 << i, 2 << i, n, SMALL_CHAR);
do_test (8 - i, 2 * i, 8 << i, 2 << i, n, SMALL_CHAR);
+
+ do_test (0, 0, 8 << i, 8 << i, SIZE_MAX, SMALL_CHAR);
+ do_test (8 - i, 2 * i, 8 << i, 8 << i, SIZE_MAX, SMALL_CHAR);
+ do_test (0, 0, 8 << i, 2 << i, SIZE_MAX, SMALL_CHAR);
+ do_test (8 - i, 2 * i, 8 << i, 2 << i, SIZE_MAX, SMALL_CHAR);
}
for (i = 1; i < 8; ++i)
@@ -297,6 +308,10 @@ test_main (void)
do_test (i, 2 * i, 8 << i, 1, n, SMALL_CHAR);
do_test (2 * i, i, 8 << i, 1, n, BIG_CHAR);
do_test (i, i, 8 << i, 10, n, SMALL_CHAR);
+
+ do_test (i, 2 * i, 8 << i, 1, SIZE_MAX, SMALL_CHAR);
+ do_test (2 * i, i, 8 << i, 1, SIZE_MAX, BIG_CHAR);
+ do_test (i, i, 8 << i, 10, SIZE_MAX, SMALL_CHAR);
}
}
diff --git a/sysdeps/i386/i686/multiarch/strcat-sse2.S b/sysdeps/i386/i686/multiarch/strcat-sse2.S
index 145ae66..6359c73 100644
--- a/sysdeps/i386/i686/multiarch/strcat-sse2.S
+++ b/sysdeps/i386/i686/multiarch/strcat-sse2.S
@@ -227,6 +227,8 @@ L(StartStrcpyPart):
pxor %xmm0, %xmm0
# ifdef USE_AS_STRNCAT
add %ecx, %ebx
+ sbb %edx, %edx
+ or %edx, %ebx
# endif
sub %ecx, %eax
jmp L(Unalign16Both)
diff --git a/sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S b/sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
index c038043..6a5ab7a 100644
--- a/sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
+++ b/sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
@@ -99,6 +99,8 @@ L(Unalign16Both):
sub %rcx, %rdi
# ifdef USE_AS_STRNCPY
add %rcx, %r8
+ sbb %rcx, %rcx
+ or %rcx, %r8
# endif
mov $16, %rcx
movdqa (%rsi, %rcx), %xmm1