---
 procps/top.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/procps/top.c b/procps/top.c
index b777c494e..fac832833 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -694,10 +694,14 @@ static NOINLINE void display_process_list(int lines_rem, 
int scr_width)
                CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift);
 #endif
 
-               if (s->vsz >= 100000)
-                       sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
+               if ((s->vsz / (1024 * 1024)) >= 100000)
+                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldt", 
s->vsz/(1024 * 1024 * 1024));
+               else if ((s->vsz / 1024) >= 100000)
+                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldg", 
s->vsz/(1024 * 1024));
+               else if (s->vsz >= 100000)
+                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldm", 
s->vsz/1024);
                else
-                       sprintf(vsz_str_buf, "%7lu", s->vsz);
+                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%7lu", 
s->vsz);
                /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
                col = snprintf(line_buf, scr_width,
                                "\n" "%5u%6u %-8.8s %s%s" FMT
-- 
2.16.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to