eta: fix run_str_condensed overflow with maximum jobs
[fio.git] / eta.c
diff --git a/eta.c b/eta.c
index 8b77dafaf9700b30996c1650788ec6c554598cdf..c9b2e9139aea2f05c15f93a2d836da8dd5c68d5b 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -9,7 +9,7 @@
 #include "lib/pow2.h"
 
 static char __run_str[REAL_MAX_JOBS + 1];
-static char run_str[__THREAD_RUNSTR_SZ(REAL_MAX_JOBS)];
+static char run_str[__THREAD_RUNSTR_SZ(REAL_MAX_JOBS) + 1];
 
 static void update_condensed_str(char *rstr, char *run_str_condensed)
 {
@@ -601,6 +601,9 @@ void display_thread_status(struct jobs_eta *je)
                                rate_str[DDIR_READ], rate_str[DDIR_WRITE],
                                iops_str[DDIR_READ], iops_str[DDIR_WRITE],
                                eta_str);
+               /* If truncation occurred adjust l so p is on the null */
+               if (l >= left)
+                       l = left - 1;
                p += l;
                if (l >= 0 && l < linelen_last)
                        p += sprintf(p, "%*s", linelen_last - l, "");