From ddb80b92107fde8f5954daf56fc5eda6d5e143cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 29 May 2008 03:37:58 +0000 Subject: [PATCH] Rewrite sliding window code so it doesn't have a integer overrun. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23213 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/ftp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/appl/ftp/ftp/ftp.c b/appl/ftp/ftp/ftp.c index 47d0c471f..678355548 100644 --- a/appl/ftp/ftp/ftp.c +++ b/appl/ftp/ftp/ftp.c @@ -595,11 +595,12 @@ copy_stream (FILE * from, FILE * to) return 0; off = 0; while (off != st.st_size) { - size_t len = BLOCKSIZE; + size_t len; ssize_t res; - if (off + len > st.st_size) - len = st.st_size - off; + len = st.st_size - off; + if (len > BLOCKSIZE) + len = BLOCKSIZE; chunk = mmap (0, len, PROT_READ, MAP_SHARED, fileno (from), off); if (chunk == (void *) MAP_FAILED) {