diff options
author | Martin Sebor <msebor@redhat.com> | 2019-11-22 00:51:16 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-11-21 17:51:16 -0700 |
commit | 7028c2179cc349653c5578fb5774389b1fffdaf1 (patch) | |
tree | 163d5cfb955c2c0185626f0583a94ffe7417f3a1 | |
parent | fb6543092ebc796c2aa8c9792a8e052f31a4afcc (diff) | |
download | gcc-7028c2179cc349653c5578fb5774389b1fffdaf1.zip gcc-7028c2179cc349653c5578fb5774389b1fffdaf1.tar.gz gcc-7028c2179cc349653c5578fb5774389b1fffdaf1.tar.bz2 |
strlenopt-66.c: Avoid buffer overflow.
gcc/testsuite/ChangeLog:
* gcc.dg/strlenopt-66.c: Avoid buffer overflow. Add more test cases.
From-SVN: r278608
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strlenopt-66.c | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a3d3e735..38ff666 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-11-21 Martin Sebor <msebor@redhat.com> + + * gcc.dg/strlenopt-66.c: Avoid buffer overflow. Add more test cases. + 2019-11-21 Joseph Myers <joseph@codesourcery.com> * 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 4ba31a8..469f3fd 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); } |