From 1d272416412b0c867224a2b667e6b6124cbc26e8 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 20 Sep 2016 21:58:34 -0600 Subject: [PATCH] stat: check if ctime_r() ends in a newline before stripping Signed-off-by: Jens Axboe --- stat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stat.c b/stat.c index c9148ad7..3c72a6cd 100644 --- a/stat.c +++ b/stat.c @@ -1650,7 +1650,8 @@ void __show_run_stats(void) os_ctime_r((const time_t *) &now.tv_sec, time_buf, sizeof(time_buf)); - time_buf[strlen(time_buf) - 1] = '\0'; + if (time_buf[strlen(time_buf) - 1] == '\n') + time_buf[strlen(time_buf) - 1] = '\0'; root = json_create_object(); json_object_add_value_string(root, "fio version", fio_version_string); -- 2.25.1