From c072ef1ebab052bdecb0d9a52c14813728f83859 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 22 Jul 2016 09:21:09 -0400 Subject: 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 --- glnx-console.c | 6 ++++-- 1 file 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 { -- cgit v1.2.1