mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
diff-delta: fix encoding size that would not fit in "unsigned int"
The current delta code produces incorrect pack objects for files > 4GB, because the size is copied from size_t field to "unsigned int" variables during the encoding process. Signed-off-by: Martin Koegler <martin.koegler@chello.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4274c698f4
commit
3f0a67a1f6
24
diff-delta.c
24
diff-delta.c
|
@ -319,7 +319,9 @@ create_delta(const struct delta_index *index,
|
||||||
const void *trg_buf, unsigned long trg_size,
|
const void *trg_buf, unsigned long trg_size,
|
||||||
unsigned long *delta_size, unsigned long max_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;
|
int inscnt;
|
||||||
const unsigned char *ref_data, *ref_top, *data, *top;
|
const unsigned char *ref_data, *ref_top, *data, *top;
|
||||||
unsigned char *out;
|
unsigned char *out;
|
||||||
|
@ -336,20 +338,20 @@ create_delta(const struct delta_index *index,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* store reference buffer size */
|
/* store reference buffer size */
|
||||||
i = index->src_size;
|
l = index->src_size;
|
||||||
while (i >= 0x80) {
|
while (l >= 0x80) {
|
||||||
out[outpos++] = i | 0x80;
|
out[outpos++] = l | 0x80;
|
||||||
i >>= 7;
|
l >>= 7;
|
||||||
}
|
}
|
||||||
out[outpos++] = i;
|
out[outpos++] = l;
|
||||||
|
|
||||||
/* store target buffer size */
|
/* store target buffer size */
|
||||||
i = trg_size;
|
l = trg_size;
|
||||||
while (i >= 0x80) {
|
while (l >= 0x80) {
|
||||||
out[outpos++] = i | 0x80;
|
out[outpos++] = l | 0x80;
|
||||||
i >>= 7;
|
l >>= 7;
|
||||||
}
|
}
|
||||||
out[outpos++] = i;
|
out[outpos++] = l;
|
||||||
|
|
||||||
ref_data = index->src_buf;
|
ref_data = index->src_buf;
|
||||||
ref_top = ref_data + index->src_size;
|
ref_top = ref_data + index->src_size;
|
||||||
|
|
Loading…
Reference in a new issue