Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
zsync.c: in zsync_needed_byte_ranges, don't return a range that goes …
Browse files Browse the repository at this point in the history
…beyond the end of the file (clip to zs->filelen instead)
  • Loading branch information
merlino authored and gianm committed Jan 17, 2012
1 parent 02ca8a1 commit 2b8e229
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions c/libzsync/zsync.c
Expand Up @@ -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 */

Expand Down

0 comments on commit 2b8e229

Please sign in to comment.