From 3aebc597181a97c7b064f04d8e8aa30f79c51451 Mon Sep 17 00:00:00 2001 From: Renlin Li Date: Thu, 31 Aug 2017 09:18:22 +0000 Subject: [PATCH] [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 Aaron Sawdey * gcc.dg/memcmp-1.c (test_strncmp): Use memcpy instead of strcpy. Co-Authored-By: Aaron Sawdey From-SVN: r251554 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/memcmp-1.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index afaa91943ca..98b269e3dbf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-31 Renlin Li + Aaron Sawdey + + * gcc.dg/memcmp-1.c: Use memcpy instead of strcpy. + 2017-08-30 Bill Schmidt PR tree-optimization/81987 diff --git a/gcc/testsuite/gcc.dg/memcmp-1.c b/gcc/testsuite/gcc.dg/memcmp-1.c index 828a0caf135..ace7173f754 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(); \ -- 2.30.2