git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/2] Fix delta integer overflows
@ 2017-08-10  7:01 Martin Koegler
  2017-08-10  7:01 ` [PATCH V2 2/2] Convert size datatype to size_t Martin Koegler
  2017-08-10 20:07 ` [PATCH V2 1/2] Fix delta integer overflows Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Martin Koegler @ 2017-08-10  7:01 UTC (permalink / raw)
  To: git, gitster, Johannes.Schindelin; +Cc: Martin Koegler

From: Martin Koegler <martin.koegler@chello.at>

The current delta code produces incorrect pack objects for files > 4GB.

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
For next.

 diff-delta.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/diff-delta.c b/diff-delta.c
index 3797ce6..cd238c8 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;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-08-11 18:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-10  7:01 [PATCH V2 1/2] Fix delta integer overflows Martin Koegler
2017-08-10  7:01 ` [PATCH V2 2/2] Convert size datatype to size_t Martin Koegler
2017-08-10 14:46   ` Johannes Schindelin
2017-08-10 22:04   ` Junio C Hamano
2017-08-11  7:12     ` Martin Koegler
2017-08-10 20:07 ` [PATCH V2 1/2] Fix delta integer overflows Junio C Hamano
2017-08-10 20:36   ` Jeff King
2017-08-11 18:43     ` Junio C Hamano
2017-08-11  7:43   ` Martin Koegler
2017-08-11 18:40     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).