FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 08-11-2012, 01:48 PM
Allan McRae
 
Default 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>
---

Replicate with linux-lts-3.0.39-1 in the Arch Linux [core] repo and a terminal
with 80 width.

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 7f7f6a7..995308c 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -296,7 +296,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("
%-*s", (int)indent, "");
cidx = indent;
--
1.7.11.4
 

Thread Tools




All times are GMT. The time now is 03:30 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org