[patch] Buffer overflow
Martin Nagy <[email protected]> Tue, 11 Dec 2007 18:03:35 +0100
| Newsgroups | gmane.network.lftp.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi. On lftp-3.5.14 (and development version in CVS) there is a small
buffer used to store the progress string when downloading.
From FileCopy.cc:512:
int pct=GetPercentDone();
if(pct==-1)
return "";
static char buf[6];
sprintf(buf,"(%d%%) ",pct);
Since GetPercentDone() can return 100, the buffer is obviously small.
For more information on how to reproduce this and a backtrace, please
see https://bugzilla.redhat.com/show_bug.cgi?id=414051 . The attached
patch fixes the problem, it was made against CVS.
Martin Nagy
lftp.progress_overflow.patch
(text/x-patch, 369 B)
--- FileCopy.cc.progress_overflow 2007-12-11 18:00:04.000000000 +0100
+++ FileCopy.cc 2007-12-11 18:00:37.000000000 +0100
@@ -512,8 +512,8 @@
int pct=GetPercentDone();
if(pct==-1)
return "";
- static char buf[6];
- sprintf(buf,"(%d%%) ",pct);
+ static char buf[8];
+ snprintf(buf, 8, "(%d%%) ",pct);
return buf;
}
float FileCopy::GetRate()