From 4e59d0f3a3ff569bddb31fe6927a9faf204ae9bf Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 14 Mar 2014 08:41:39 -0600 Subject: [PATCH] Bump length of description field to 256 chars Ensure that string always end up \0 terminated, too. Signed-off-by: Jens Axboe --- server.c | 6 +++--- server.h | 2 +- stat.c | 6 +++--- stat.h | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/server.c b/server.c index dc70616a..2f121628 100644 --- 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); diff --git a/server.h b/server.h index 8f79c14a..3a279f0b 100644 --- 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 c2c717b5..f84ce530 100644 --- 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 bc4f6da4..3f68305a 100644 --- 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; -- 2.25.1