aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenlin Li <renlin.li@arm.com>2017-08-31 09:18:22 +0000
committerRenlin Li <renlin@gcc.gnu.org>2017-08-31 09:18:22 +0000
commit3aebc597181a97c7b064f04d8e8aa30f79c51451 (patch)
treef1790f4ad47d5bc63465c9f6e40b64f401dcccc2
parent4b0d36db3c835ce9e3080f5203bd8ea7cdf43b5c (diff)
downloadgcc-3aebc597181a97c7b064f04d8e8aa30f79c51451.zip
gcc-3aebc597181a97c7b064f04d8e8aa30f79c51451.tar.gz
gcc-3aebc597181a97c7b064f04d8e8aa30f79c51451.tar.bz2
[TESTSUITE]Use memcpy instead of strcpy in testsuite/gcc.dg/memcmp-1.c
strcpy will keep reading and writing memory if the string is not terminated with null character. In this case, it may visit memory beyond the boundary. gcc/testsuite/ 2017-08-31 Renlin Li <renlin.li@arm.com> Aaron Sawdey <acsawdey@linux.vnet.ibm.com> * gcc.dg/memcmp-1.c (test_strncmp): Use memcpy instead of strcpy. Co-Authored-By: Aaron Sawdey <acsawdey@linux.vnet.ibm.com> From-SVN: r251554
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/memcmp-1.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index afaa919..98b269e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-31 Renlin Li <renlin.li@arm.com>
+ Aaron Sawdey <acsawdey@linux.vnet.ibm.com>
+
+ * gcc.dg/memcmp-1.c: Use memcpy instead of strcpy.
+
2017-08-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/81987
diff --git a/gcc/testsuite/gcc.dg/memcmp-1.c b/gcc/testsuite/gcc.dg/memcmp-1.c
index 828a0ca..ace7173 100644
--- a/gcc/testsuite/gcc.dg/memcmp-1.c
+++ b/gcc/testsuite/gcc.dg/memcmp-1.c
@@ -110,8 +110,8 @@ static void test_strncmp_ ## SZ ## _ ## ALIGN (const char *str1, const char *str
{ \
a = three+i*ALIGN+j*(4096-2*i*ALIGN); \
b = four+i*ALIGN+j*(4096-2*i*ALIGN); \
- strcpy(a,str1); \
- strcpy(b,str2); \
+ memcpy(a,str1,SZ); \
+ memcpy(b,str2,SZ); \
r = strncmp(a,b,SZ); \
if ( r < 0 && !(expect < 0) ) abort(); \
if ( r > 0 && !(expect > 0) ) abort(); \