summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxstat
diff options
context:
space:
mode:
authorJoel Sherrill <joel@rtems.org>2017-06-15 12:42:59 -0500
committerJoel Sherrill <joel@rtems.org>2017-06-21 12:50:31 -0500
commitb8b4b7d429b4a1091800891e02cf9e1605c2e60d (patch)
treece4c6a0174a422392fcd9e98aa3a55d5d33839ae /testsuites/psxtests/psxstat
parentpsximfs02/init.c: Avoid potential string overflow (diff)
downloadrtems-b8b4b7d429b4a1091800891e02cf9e1605c2e60d.tar.bz2
psxstat/test.c: Avoid potential string overflow
Diffstat (limited to 'testsuites/psxtests/psxstat')
-rw-r--r--testsuites/psxtests/psxstat/test.c7
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 );
}