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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]