Commit Diff
- Commit:
5de743f8fddcaaf2912ffc92dce239aa6227d6d0
- From:
- Stefan Sperling <stsp@stsp.name>
- Date:
- Message:
- fix seek to incorrect offset in the delta base when creating deltas The stretchblk() function needs to compare data located after the block which has just been matched. However, upon entry it was resetting the file pointer of the delta base to the beginning(!) of the block. The other file is correctly positioned after the block. In many cases the data won't match and stretchblk() will not stretch the matched block. But when the data did happen to match this resulted in a bogus delta, and wrong file contents when the delta was applied. Fix this by setting the delta base file pointer to end of the block. Problem reported by naddy after our server refused a pack file which was sent by 'got send'. I could reproduce the issue by running the 'gotadmin pack' command on a copy of naddy's repository. ok naddy
- Actions:
- Patch | Tree
--- lib/deltify.c +++ lib/deltify.c @@ -325,7 +325,8 @@ stretchblk(FILE *basefile, off_t base_offset0, struct size_t base_r, r, i; int buf_equal = 1; - if (fseeko(basefile, base_offset0 + block->offset, SEEK_SET) == -1) + if (fseeko(basefile, base_offset0 + block->offset + *blocklen, + SEEK_SET) == -1) return got_error_from_errno("fseeko"); while (buf_equal && *blocklen < (1 << 24) - 1) {