mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
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 <allan@archlinux.org>
This commit is contained in:
parent
7262f4bed4
commit
8f5ee72974
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user