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

[PATCH] Cast things properly to handle >2G files.

From
Alfred M. Szmidt <ams@gnu.org>
Date
Jun 14, 2009, 20:03 UTC
Message-ID
<E1MFvux-0001ix-I7@fencepost.gnu.org>

This small patch fixes things so that repack, fsck, and other things work on >2GiB files. There are still some other problems (cloning over ssh being one), but this makes it atleast possible to handle such files.

(not subscribed, please CC)
---
 delta.h       |    2 +-
 patch-delta.c |    2 +-
 sha1_file.c   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/delta.h b/delta.h
index 40ccf5a..b3acc72 100644
--- a/delta.h
+++ b/delta.h
@@ -95,7 +95,7 @@ static inline unsigned long get_delta_hdr_size(const unsigned char **datap,
 	int i = 0;
 	do {
 		cmd = *data++;
-		size |= (cmd & ~0x80) << i;
+		size |= (cmd & ~0x80UL) << i;
 		i += 7;
 	} while (cmd & 0x80 && data < top);
 	*datap = data;
diff --git a/patch-delta.c b/patch-delta.c
index ed9db81..a9ad2bc 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -44,7 +44,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
 			if (cmd & 0x01) cp_off = *data++;
 			if (cmd & 0x02) cp_off |= (*data++ << 8);
 			if (cmd & 0x04) cp_off |= (*data++ << 16);
-			if (cmd & 0x08) cp_off |= (*data++ << 24);
+			if (cmd & 0x08) cp_off |= ((unsigned long) *data++ << 24);
 			if (cmd & 0x10) cp_size = *data++;
 			if (cmd & 0x20) cp_size |= (*data++ << 8);
 			if (cmd & 0x40) cp_size |= (*data++ << 16);
diff --git a/sha1_file.c b/sha1_file.c
index e73cd4f..4566ea1 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1176,7 +1176,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
 			return 0;
 		}
 		c = buf[used++];
-		size += (c & 0x7f) << shift;
+		size += (c & 0x7fUL) << shift;
 		shift += 7;
 	}
 	*sizep = size;
-- 
1.6.3.2.225.gb8364.dirty
Next: Johannes Schindelin
Message 1 of 23 in “Cast things properly to handle >2G files.”
  1. Cast things properly to handle >2G files.Alfred M. Szmidt, Jun 14, 2009
  2. Johannes SchindelinJun 14, 2009
  3. Nicolas PitreJun 15, 2009
  4. Alfred M. SzmidtJun 15, 2009
  5. Junio C HamanoJun 15, 2009
  6. Johannes SchindelinJun 15, 2009
  7. Linus TorvaldsJun 15, 2009
  8. Alfred M. SzmidtJun 17, 2009
  9. Linus TorvaldsJun 17, 2009
  10. Alfred M. SzmidtJun 17, 2009
  11. Linus TorvaldsJun 17, 2009
  12. Junio C HamanoJun 17, 2009
  13. Fix big left-shifts of unsigned charLinus Torvalds, Jun 18, 2009
  14. Johannes SchindelinJun 18, 2009
  15. Junio C HamanoJun 18, 2009
  16. Linus TorvaldsJun 18, 2009
  17. Johannes SchindelinJun 18, 2009
  18. Linus TorvaldsJun 18, 2009
  19. Fix various sparse warnings in the git source codeLinus Torvalds, Jun 18, 2009
  20. Matthieu MoyJun 18, 2009
  21. Linus TorvaldsJun 18, 2009
  22. Linus TorvaldsJun 18, 2009
  23. Linus TorvaldsJun 17, 2009

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.