summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-09-28 14:47:56 +0900
committerJunio C Hamano <gitster@pobox.com>2017-09-28 14:47:56 +0900
commit3d09e79b27055107f51bdbc537c51b8a337b820a (patch)
treef8f398f8f524fd7fad27f6f78d8017700a3319b8
parent73ecdc606eedbfd98ec66d50d44b3374425fd13b (diff)
parent3f0a67a1f68d79f102ac11a8b6e7a72dc86be613 (diff)
downloadgit-3d09e79b27055107f51bdbc537c51b8a337b820a.tar.gz
Merge branch 'mk/diff-delta-uint-may-be-shorter-than-ulong'
The machinery to create xdelta used in pack files received the sizes of the data in size_t, but lost the higher bits of them by storing them in "unsigned int" during the computation, which is fixed. * mk/diff-delta-uint-may-be-shorter-than-ulong: diff-delta: fix encoding size that would not fit in "unsigned int"
-rw-r--r--diff-delta.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/diff-delta.c b/diff-delta.c
index 3797ce6041..cd238c8ed8 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -319,7 +319,9 @@ create_delta(const struct delta_index *index,
const void *trg_buf, unsigned long trg_size,
unsigned long *delta_size, unsigned long max_size)
{
- unsigned int i, outpos, outsize, moff, msize, val;
+ unsigned int i, val;
+ off_t outpos, moff;
+ size_t l, outsize, msize;
int inscnt;
const unsigned char *ref_data, *ref_top, *data, *top;
unsigned char *out;
@@ -336,20 +338,20 @@ create_delta(const struct delta_index *index,
return NULL;
/* store reference buffer size */
- i = index->src_size;
- while (i >= 0x80) {
- out[outpos++] = i | 0x80;
- i >>= 7;
+ l = index->src_size;
+ while (l >= 0x80) {
+ out[outpos++] = l | 0x80;
+ l >>= 7;
}
- out[outpos++] = i;
+ out[outpos++] = l;
/* store target buffer size */
- i = trg_size;
- while (i >= 0x80) {
- out[outpos++] = i | 0x80;
- i >>= 7;
+ l = trg_size;
+ while (l >= 0x80) {
+ out[outpos++] = l | 0x80;
+ l >>= 7;
}
- out[outpos++] = i;
+ out[outpos++] = l;
ref_data = index->src_buf;
ref_top = ref_data + index->src_size;