Commit 3aebc597 by Renlin Li Committed by Renlin Li

[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
parent 4b0d36db
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> 2017-08-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/81987 PR tree-optimization/81987
......
...@@ -110,8 +110,8 @@ static void test_strncmp_ ## SZ ## _ ## ALIGN (const char *str1, const char *str ...@@ -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); \ a = three+i*ALIGN+j*(4096-2*i*ALIGN); \
b = four+i*ALIGN+j*(4096-2*i*ALIGN); \ b = four+i*ALIGN+j*(4096-2*i*ALIGN); \
strcpy(a,str1); \ memcpy(a,str1,SZ); \
strcpy(b,str2); \ memcpy(b,str2,SZ); \
r = strncmp(a,b,SZ); \ r = strncmp(a,b,SZ); \
if ( r < 0 && !(expect < 0) ) abort(); \ if ( r < 0 && !(expect < 0) ) abort(); \
if ( r > 0 && !(expect > 0) ) abort(); \ if ( r > 0 && !(expect > 0) ) abort(); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment