Skip to content

Commit 3d09e79

Browse files
committed
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"
2 parents 73ecdc6 + 3f0a67a commit 3d09e79

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

diff-delta.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ create_delta(const struct delta_index *index,
319319
const void *trg_buf, unsigned long trg_size,
320320
unsigned long *delta_size, unsigned long max_size)
321321
{
322-
unsigned int i, outpos, outsize, moff, msize, val;
322+
unsigned int i, val;
323+
off_t outpos, moff;
324+
size_t l, outsize, msize;
323325
int inscnt;
324326
const unsigned char *ref_data, *ref_top, *data, *top;
325327
unsigned char *out;
@@ -336,20 +338,20 @@ create_delta(const struct delta_index *index,
336338
return NULL;
337339

338340
/* store reference buffer size */
339-
i = index->src_size;
340-
while (i >= 0x80) {
341-
out[outpos++] = i | 0x80;
342-
i >>= 7;
341+
l = index->src_size;
342+
while (l >= 0x80) {
343+
out[outpos++] = l | 0x80;
344+
l >>= 7;
343345
}
344-
out[outpos++] = i;
346+
out[outpos++] = l;
345347

346348
/* store target buffer size */
347-
i = trg_size;
348-
while (i >= 0x80) {
349-
out[outpos++] = i | 0x80;
350-
i >>= 7;
349+
l = trg_size;
350+
while (l >= 0x80) {
351+
out[outpos++] = l | 0x80;
352+
l >>= 7;
351353
}
352-
out[outpos++] = i;
354+
out[outpos++] = l;
353355

354356
ref_data = index->src_buf;
355357
ref_top = ref_data + index->src_size;

0 commit comments

Comments
 (0)