From b8b4b7d429b4a1091800891e02cf9e1605c2e60d Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 15 Jun 2017 12:42:59 -0500 Subject: psxstat/test.c: Avoid potential string overflow --- testsuites/psxtests/psxstat/test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testsuites/psxtests/psxstat/test.c b/testsuites/psxtests/psxstat/test.c index e489180122..b616f55746 100644 --- a/testsuites/psxtests/psxstat/test.c +++ b/testsuites/psxtests/psxstat/test.c @@ -512,16 +512,19 @@ void make_many_symlinks( char name2[5]; char *link_file; + /* limit the link_count to ensure filename buffer doesn't overflow */ + rtems_test_assert( link_count < 1000 ); + link_file = real_file; for (i=1; i < link_count; i++) { - sprintf( name1, "%d", i ); + sprintf( name1, "%04d", i ); make_a_symlink( link_file, name1 ); strcpy( name2, name1 ); link_file = name2; } for (i=1; i < link_count; i++) { - sprintf( name1, "%d", i ); + sprintf( name1, "%04d", i ); stat_a_file( name1 ); lstat_a_file( name1 ); } -- cgit v1.2.3