Whamcloud - gitweb
LU-9835 utils: Properly maintain remaining buffer length in jt_opt_threads 63/28363/4
authorOleg Drokin <green@whamcloud.com>
Fri, 12 Jul 2019 10:29:23 +0000 (06:29 -0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 27 Jul 2019 00:21:34 +0000 (00:21 +0000)
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 <oleg.drokin@intel.com>
Reviewed-on: https://review.whamcloud.com/28363
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/obd.c

index 15a63b5..2ab9604 100644 (file)
@@ -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);