From: Martin Sebor Date: Fri, 22 Nov 2019 00:51:16 +0000 (+0000) Subject: strlenopt-66.c: Avoid buffer overflow. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7028c2179cc349653c5578fb5774389b1fffdaf1;p=gcc.git strlenopt-66.c: Avoid buffer overflow. gcc/testsuite/ChangeLog: * gcc.dg/strlenopt-66.c: Avoid buffer overflow. Add more test cases. From-SVN: r278608 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a3d3e73568e..38ff666a493 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-11-21 Martin Sebor + + * gcc.dg/strlenopt-66.c: Avoid buffer overflow. Add more test cases. + 2019-11-21 Joseph Myers * gcc.dg/c2x-attr-fallthrough-6.c: New test. Split out from diff --git a/gcc/testsuite/gcc.dg/strlenopt-66.c b/gcc/testsuite/gcc.dg/strlenopt-66.c index 4ba31a845b0..469f3fd8457 100644 --- a/gcc/testsuite/gcc.dg/strlenopt-66.c +++ b/gcc/testsuite/gcc.dg/strlenopt-66.c @@ -1,7 +1,7 @@ /* PRE tree-optimization/90626 - fold strcmp(a, b) == 0 to zero when one string length is exact and the other is unequal { dg-do run } - { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + { dg-options "-O2 -Wall" } */ #include "strlenopt.h" @@ -103,6 +103,12 @@ int main (void) test_strncmp_a4_cond_s5_s2_2 ("12", 0); test_strncmp_a4_cond_a5_s2_5 ("12", "1234", 0); - test_strncmp_a4_cond_a5_a3_n ("12", "123", "1234", 0, 2); - test_strncmp_a4_cond_a5_a3_n ("123", "12", "12", 1, 3); + test_strncmp_a4_cond_a5_a3_n ("12", "1", "1", 0, 1); + test_strncmp_a4_cond_a5_a3_n ("", "1", "1234", 1, 1); + + test_strncmp_a4_cond_a5_a3_n ("12", "12", "1", 0, 2); + test_strncmp_a4_cond_a5_a3_n ("", "12", "1234", 1, 2); + + test_strncmp_a4_cond_a5_a3_n ("12", "123", "1", 0, 2); + test_strncmp_a4_cond_a5_a3_n ("", "123", "1234", 1, 3); }