Bump length of description field to 256 chars
authorJens Axboe <axboe@fb.com>
Fri, 14 Mar 2014 14:41:39 +0000 (08:41 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 14 Mar 2014 14:41:39 +0000 (08:41 -0600)
Ensure that string always end up \0 terminated, too.

Signed-off-by: Jens Axboe <axboe@fb.com>
server.c
server.h
stat.c
stat.h

index dc70616a0826572efc79f4d0fcb35b8e2cc67f03..2f1216288b8a1b6bfc9160c2b318d67a5954b16f 100644 (file)
--- a/server.c
+++ b/server.c
@@ -987,9 +987,9 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs)
 
        memset(&p, 0, sizeof(p));
 
-       strcpy(p.ts.name, ts->name);
-       strcpy(p.ts.verror, ts->verror);
-       strcpy(p.ts.description, ts->description);
+       strncpy(p.ts.name, ts->name, FIO_JOBNAME_SIZE - 1);
+       strncpy(p.ts.verror, ts->verror, FIO_VERROR_SIZE - 1);
+       strncpy(p.ts.description, ts->description, FIO_JOBDESC_SIZE - 1);
 
        p.ts.error              = cpu_to_le32(ts->error);
        p.ts.thread_number      = cpu_to_le32(ts->thread_number);
index 8f79c14ae33474cdf39418b147b4991779926cd4..3a279f0b1095c33b6e2a6f9fc7155f7a7ad3da35 100644 (file)
--- a/server.h
+++ b/server.h
@@ -38,7 +38,7 @@ struct fio_net_cmd_reply {
 };
 
 enum {
-       FIO_SERVER_VER                  = 32,
+       FIO_SERVER_VER                  = 33,
 
        FIO_SERVER_MAX_FRAGMENT_PDU     = 1024,
 
diff --git a/stat.c b/stat.c
index c2c717b56f80426519f3b9376425a2761d62b9ce..f84ce5300f605736b5ef8b9556286792b2b53cd8 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1232,12 +1232,12 @@ static void __show_run_stats(void)
                        /*
                         * These are per-group shared already
                         */
-                       strncpy(ts->name, td->o.name, FIO_JOBNAME_SIZE);
+                       strncpy(ts->name, td->o.name, FIO_JOBNAME_SIZE - 1);
                        if (td->o.description)
                                strncpy(ts->description, td->o.description,
-                                               FIO_JOBNAME_SIZE);
+                                               FIO_JOBDESC_SIZE - 1);
                        else
-                               memset(ts->description, 0, FIO_JOBNAME_SIZE);
+                               memset(ts->description, 0, FIO_JOBDESC_SIZE);
 
                        /*
                         * If multiple entries in this group, this is
diff --git a/stat.h b/stat.h
index bc4f6da483663a2d84921083863c29f4fa92c313..3f68305adb2841c3aac8f98de942be94b8e23d5b 100644 (file)
--- a/stat.h
+++ b/stat.h
@@ -114,6 +114,7 @@ struct group_run_stats {
 
 #define MAX_PATTERN_SIZE       512
 #define FIO_JOBNAME_SIZE       128
+#define FIO_JOBDESC_SIZE       256
 #define FIO_VERROR_SIZE                128
 
 struct thread_stat {
@@ -123,7 +124,7 @@ struct thread_stat {
        uint32_t thread_number;
        uint32_t groupid;
        uint32_t pid;
-       char description[FIO_JOBNAME_SIZE];
+       char description[FIO_JOBDESC_SIZE];
        uint32_t members;
        uint32_t unified_rw_rep;