[libglnx] text_percent_internal: compare uints before printing



commit c072ef1ebab052bdecb0d9a52c14813728f83859
Author: Jonathan Lebon <jlebon redhat com>
Date:   Fri Jul 22 09:21:09 2016 -0400

    text_percent_internal: compare uints before printing
    
    A wild sordid tale of substractions and unsigned integers leads this
    team of variables down a loonng path...
    
    Reported-by: Gatis Paeglis <gatis paeglis qt io>

 glnx-console.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/glnx-console.c b/glnx-console.c
index d40702e..416d276 100644
--- a/glnx-console.c
+++ b/glnx-console.c
@@ -221,9 +221,11 @@ text_percent_internal (const char *text,
 
   if (percentage == -1)
     {
-      const guint spacelen = ncolumns - input_textlen;
       fwrite (text, 1, input_textlen, stdout);
-      printpad (spaces, n_spaces, spacelen);
+
+      /* Overwrite remaining space, if any */
+      if (ncolumns > input_textlen)
+        printpad (spaces, n_spaces, ncolumns - input_textlen);
     }
   else
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]