Rewrite sliding window code so it doesn't have a integer overrun.
authorLove Hörnquist Åstrand <lha@kth.se>
Thu, 29 May 2008 03:37:58 +0000 (03:37 +0000)
committerLove Hörnquist Åstrand <lha@kth.se>
Thu, 29 May 2008 03:37:58 +0000 (03:37 +0000)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23213 ec53bebd-3082-4978-b11e-865c3cabbd6b

appl/ftp/ftp/ftp.c

index 47d0c471fb466365a78044947d242bd9f2081eb1..6783555487c95a86e6902830eb25edae8d38d61f 100644 (file)
@@ -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) {