diff options
author | Joel Sherrill <joel@rtems.org> | 2017-06-15 12:42:59 -0500 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2017-06-21 12:50:31 -0500 |
commit | b8b4b7d429b4a1091800891e02cf9e1605c2e60d (patch) | |
tree | ce4c6a0174a422392fcd9e98aa3a55d5d33839ae /testsuites/psxtests | |
parent | 9d945b5fff11b8a435db03c10a3c8be2a5141122 (diff) |
psxstat/test.c: Avoid potential string overflow
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r-- | testsuites/psxtests/psxstat/test.c | 7 |
1 files 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 ); } |