From bac36f90818d70c211a40bbae6849abb044319c7 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Fri, 12 Jul 2019 06:29:23 -0400 Subject: [PATCH] LU-9835 utils: Properly maintain remaining buffer length in jt_opt_threads When we write to a buffer, we do need to reduce the size of it, not just move the starting pointer. Test-Parameters: trivial Change-Id: I688e31d5434fb3040985b65a092d56ca30b69941 Signed-off-by: Oleg Drokin Reviewed-on: https://review.whamcloud.com/28363 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: James Simmons Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- lustre/utils/obd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 15a63b5..2ab9604 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -685,7 +685,7 @@ static void parent_sighandler (int sig) int jt_opt_threads(int argc, char **argv) { - static char cmdstr[128]; + static char cmdstr[129]; sigset_t saveset; sigset_t sigset; struct sigaction sigact; @@ -720,8 +720,9 @@ int jt_opt_threads(int argc, char **argv) if (verbose != 0) { snprintf(cmdstr, sizeof(cmdstr), "%s", argv[4]); for (i = 5; i < argc; i++) - snprintf(cmdstr + strlen(cmdstr), sizeof(cmdstr), - " %s", argv[i]); + snprintf(cmdstr + strlen(cmdstr), + sizeof(cmdstr) - strlen(cmdstr), + " %s", argv[i]); printf("%s: starting %ld threads on device %s running %s\n", argv[0], threads, argv[3], cmdstr); -- 1.8.3.1