Whamcloud - gitweb
LU-8066 lfsck: use underscores in lfsck status files
[fs/lustre-release.git] / lustre / tests / fsx.c
index aa8aaee..fb475ce 100644 (file)
@@ -57,6 +57,7 @@
 #include <unistd.h>
 #include <stdarg.h>
 #include <errno.h>
+#include <libcfs/util/string.h>
 
 #define NUMPRINTCOLUMNS 32     /* # columns of data to print on each line */
 
@@ -115,8 +116,8 @@ char        *original_buf;                  /* a pointer to the original data */
 char   *good_buf;                      /* a pointer to the correct data */
 char   *temp_buf;                      /* a pointer to the current data */
 char   *fname;                         /* name of our test file */
-char   logfile[1024];                  /* name of our log file */
-char   goodfile[1024];                 /* name of our test file */
+char   logfile[PATH_MAX];              /* name of our log file */
+char   goodfile[PATH_MAX];             /* name of our test file */
 
 off_t          file_size = 0;
 off_t          biggest = 0;
@@ -227,10 +228,10 @@ fill_tf_buf(const struct test_file *tf)
                return "";
 
        if (max_tf_len == 0)
-               max_tf_len = snprintf(tf_buf, sizeof(tf_buf) - 1,
+               max_tf_len = scnprintf(tf_buf, sizeof(tf_buf) - 1,
                                      "%u", num_test_files - 1);
 
-       sprintf(tf_buf, "[%0*lu]", max_tf_len,
+       snprintf(tf_buf, sizeof(tf_buf), "[%0*lu]", max_tf_len,
                (unsigned long)(tf - test_files));
 
        return tf_buf;
@@ -1278,9 +1279,9 @@ main(int argc, char **argv)
                        randomoplen = 0;
                        break;
                case 'P':
-                       strncpy(goodfile, optarg, sizeof(goodfile));
+                       strncpy(goodfile, optarg, sizeof(goodfile) - 1);
                        strcat(goodfile, "/");
-                       strncpy(logfile, optarg, sizeof(logfile));
+                       strncpy(logfile, optarg, sizeof(logfile) - 1);
                        strcat(logfile, "/");
                        dirpath = 1;
                        break;