Index: testsuites/fstests/fsrename/test.c
===================================================================
--- testsuites/fstests/fsrename/test.c	(revision 27d240e050697cf3d5b1632fafd2312c5bc26e52)
+++ testsuites/fstests/fsrename/test.c	(revision f68401e3f59d1eee71971399b2bce052b8c13357)
@@ -14,4 +14,5 @@
 #include "fstest.h"
 #include "fs_config.h"
+#include "fstest_support.h"
 #include "pmacros.h"
 
@@ -26,11 +27,9 @@
 const char rtems_test_name[] = "FSRENAME " FILESYSTEM;
 
-void test_initialize_filesystem (void);
-void test_shutdown_filesystem (void);
-
 static void symbolic_link_test (void)
 {
   int fd;
   int status;
+  int rv;
 
   const char *name01 = "name01";
@@ -146,8 +145,10 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/test", symlink01);
+  rv = snprintf (path01, sizeof(path01), "%s/test", symlink01);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (ELOOP, rename, path01, name01);
 
-  sprintf (path01, "%s/test", symlink02);
+  rv = snprintf (path01, sizeof(path01), "%s/test", symlink02);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (ELOOP, rename, path01, name01);
 
@@ -177,8 +178,10 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/test", symlink01);
+  rv = snprintf (path01, sizeof(path01), "%s/test", symlink01);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (ELOOP, rename, name01, path01);
 
-  sprintf (path01, "%s/test", symlink02);
+  rv = snprintf (path01, sizeof(path01), "%s/test", symlink02);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (ELOOP, rename, name01, path01);
 
@@ -210,4 +213,5 @@
   int fd;
   int status;
+  int rv;
 
   const char *name01 = "name01";
@@ -265,5 +269,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir01, name02);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name02);
+  rtems_test_assert (rv < sizeof(path01));
   status = link (name01, path01);
   rtems_test_assert (status == 0);
@@ -298,4 +303,5 @@
   int fd;
   int status;
+  int rv;
   int i;
 
@@ -384,5 +390,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir02, dir01);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir02, dir01);
+  rtems_test_assert (rv < sizeof(path01));
   status = mkdir (path01, mode);
   rtems_test_assert (status == 0);
@@ -410,5 +417,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir02, name02);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir02, name02);
+  rtems_test_assert (rv < sizeof(path01));
   fd = creat (path01, mode);
   rtems_test_assert (fd >= 0);
@@ -471,5 +479,6 @@
   for(i = statbuf.st_nlink; i < LINK_MAX_val; i++)
   {
-    sprintf (link_name, "%s/%d", dir01, i);
+    rv = snprintf (link_name, sizeof(link_name), "%s/%d", dir01, i);
+    rtems_test_assert (rv < sizeof(link_name));
 
     status = mkdir (link_name, mode);
@@ -480,5 +489,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir01, dir01);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, dir01);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (EMLINK, rename, dir02, path01);
 
@@ -489,5 +499,6 @@
   for(i = statbuf.st_nlink; i < LINK_MAX_val; i++)
   {
-    sprintf (link_name, "%s/%d", dir01, i);
+    rv = snprintf (link_name, sizeof(link_name), "%s/%d", dir01, i);
+    rtems_test_assert (rv < sizeof(link_name));
 
     status = rmdir (link_name);
@@ -509,5 +520,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir01, name01);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01);
+  rtems_test_assert (rv < sizeof(path01));
   fd = creat (path01, mode);
   rtems_test_assert (fd >= 0);
@@ -551,5 +563,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir01, name01);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01);
+  rtems_test_assert (rv < sizeof(path01));
   fd = creat (path01, mode);
   rtems_test_assert (fd >= 0);
@@ -604,5 +617,5 @@
   int fd;
   int status;
-  int i;
+  int rv;
 
   const char *name01 = "name01";
@@ -615,5 +628,5 @@
   const char *wd = __func__;
 
-  char filename[NAME_MAX + 1];
+  char filename[NAME_MAX + 2];
   char path01[20];
 
@@ -678,5 +691,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s/%s", dir01, name01, name02);
+  rv = snprintf (path01, sizeof(path01), "%s/%s/%s", dir01, name01, name02);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (ENOENT, rename, path01, name01);
 
@@ -720,7 +734,6 @@
 
   /* Generate string with NAME_MAX + 1 length */
-
-  for(i = 0; i < NAME_MAX + 1; i++)
-    strcat(filename, "a");
+  memset(filename, 'a', NAME_MAX + 1);
+  filename[NAME_MAX + 1] = '\0';
 
   EXPECT_ERROR (ENAMETOOLONG, rename, name01, filename);
@@ -894,4 +907,5 @@
   int fd;
   int status;
+  int rv;
 
   const char *name01 = "name01";
@@ -968,5 +982,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "../%s/%s", dir01, name02);
+  rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name02);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (EACCES, rename, name01, path01);
 
@@ -984,12 +999,15 @@
   EXPECT_EQUAL (0, unlink, name01);
 
-  sprintf (path01, "../%s", dir01);
+  rv = snprintf (path01, sizeof(path01), "../%s", dir01);
+  rtems_test_assert (rv < sizeof(path01));
   status = chmod (path01, mode);
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "../%s/%s", dir01, name01);
+  rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name01);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_EQUAL (0, unlink, path01);
 
-  sprintf (path01, "../%s/%s", dir01, name02);
+  rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name02);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_EQUAL (0, unlink, path01);
 
@@ -1019,4 +1037,5 @@
   int fd;
   int status;
+  int rv;
 
   const char *name01 = "name01";
@@ -1055,5 +1074,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir01, name01);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01);
+  rtems_test_assert (rv < sizeof(path01));
   fd = creat (path01, mode);
   rtems_test_assert (fd >= 0);
@@ -1061,5 +1081,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path02, "%s/%s", dir01, name02);
+  rv = snprintf (path02, sizeof(path02), "%s/%s", dir01, name02);
+  rtems_test_assert (rv < sizeof(path02));
   fd = creat (path02, mode);
   rtems_test_assert (fd >= 0);
@@ -1093,5 +1114,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir02, name01);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir02, name01);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (EACCES, rename, path01, path02);
 
@@ -1112,5 +1134,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", dir01, name01);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_EQUAL (0, unlink, path01);
   EXPECT_EQUAL (0, unlink, path02);
@@ -1137,4 +1160,5 @@
   int fd;
   int status;
+  int rv;
 
   const char *name01 = "name01";
@@ -1169,5 +1193,6 @@
   rtems_test_assert (status == 0);
 
-  sprintf (path01, "%s/%s", BASE_FOR_TEST, name02);
+  rv = snprintf (path01, sizeof(path01), "%s/%s", BASE_FOR_TEST, name02);
+  rtems_test_assert (rv < sizeof(path01));
   EXPECT_ERROR (EXDEV, rename, name01, path01);
 
