server: ensure that incoming iolog name is NULL terminated
authorJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 17:45:34 +0000 (11:45 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 17:45:34 +0000 (11:45 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
server.c

index f65f3abfc87339211c72302e0ed7f36243382ed9..077dce5c349f67efec5c76a6371e89e2a2a4724f 100644 (file)
--- a/server.c
+++ b/server.c
@@ -1225,7 +1225,9 @@ int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name)
        pdu.nr_samples = __cpu_to_le32(log->nr_samples);
        pdu.log_type = cpu_to_le32(log->log_type);
        pdu.compressed = cpu_to_le32(use_zlib);
        pdu.nr_samples = __cpu_to_le32(log->nr_samples);
        pdu.log_type = cpu_to_le32(log->log_type);
        pdu.compressed = cpu_to_le32(use_zlib);
-       strcpy((char *) pdu.name, name);
+
+       strncpy((char *) pdu.name, name, FIO_NET_NAME_MAX);
+       pdu.name[FIO_NET_NAME_MAX - 1] = '\0';
 
        for (i = 0; i < log->nr_samples; i++) {
                struct io_sample *s = &log->log[i];
 
        for (i = 0; i < log->nr_samples; i++) {
                struct io_sample *s = &log->log[i];