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
This commit is contained in:
Love Hörnquist Åstrand
2008-05-29 03:37:58 +00:00
parent 6ffc3daa37
commit ddb80b9210

View 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) {