Permalink
Browse files

zsync.c: in zsync_needed_byte_ranges, don't return a range that goes …

…beyond the end of the file (clip to zs->filelen instead)
  • Loading branch information...
1 parent 02ca8a1 commit 2b8e229c2b70ed359e469230d94fc75b1129068c merlino committed with Jan 5, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 c/libzsync/zsync.c
View
@@ -495,6 +495,10 @@ off_t *zsync_needed_byte_ranges(struct zsync_state * zs, int *num, int type) {
for (i = 0; i < nrange; i++) {
byterange[2 * i] = blrange[2 * i] * zs->blocksize;
byterange[2 * i + 1] = blrange[2 * i + 1] * zs->blocksize - 1;
+
+ /* Don't go past the end of the file */
+ if( byterange[2*i+1] > zs->filelen - 1 )
+ byterange[2*i+1] = zs->filelen - 1;
}
free(blrange); /* And release the blocks, we're done with them */

0 comments on commit 2b8e229

Please sign in to comment.