git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH V2 1/2] Fix delta integer overflows

From
Martin Koegler <martin.koegler@chello.at>
Date
Aug 10, 2017, 07:01 UTC
Message-ID
<1502348462-4992-1-git-send-email-martin@mail.zuhause>
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
Next: Martin Koegler
Message 1 of 10 in “Fix delta integer overflows”
  1. 1/2 Fix delta integer overflowsMartin Koegler, Aug 10, 2017
  2. 2/2 Convert size datatype to size_tMartin Koegler, Aug 10, 2017
  3. Johannes SchindelinAug 10, 2017
  4. Junio C HamanoAug 10, 2017
  5. Martin KoeglerAug 11, 2017
  6. Junio C HamanoAug 10, 2017
  7. Jeff KingAug 10, 2017
  8. Junio C HamanoAug 11, 2017
  9. Martin KoeglerAug 11, 2017
  10. Junio C HamanoAug 11, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.