From 8f5ee729747937f52c2cc199a7498629ab6c9a7d Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 11 Aug 2012 23:43:43 +1000 Subject: Avoid interger overflow when calculating remaining line length When the len and cidx were changed to size_t in a8a1b093, it was possible to have an integer overflow when a line ended right at the edge of the terminal width. Signed-off-by: Allan McRae --- src/pacman/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 5079b4ce..5ed450ec 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -304,7 +304,7 @@ void indentprint(const char *str, unsigned short indent, unsigned short cols) while(q < next) { len += wcwidth(*q++); } - if(len > (cols - cidx - 1)) { + if((len + 1) > (cols - cidx)) { /* wrap to a newline and reindent */ printf("\n%-*s", (int)indent, ""); cidx = indent; -- cgit v1.2.3