Skip to content

Number truncation with 4+ GB files on 32-bit systems

Nguyễn Thái Ngọc Duy git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 1 replyIn review
  2. v15 patches 21 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7pack-objects: pass length to check_pack_crc() without truncationbuiltin/pack-objects.c sha1_file.c+2 -20 replies
2/7sha1_file.c: use type off_t* for object_info->disk_sizepbuiltin/cat-file.c cache.h+3 -30 replies
3/7index-pack: correct "len" type in unpack_data()builtin/index-pack.c+7 -70 replies
4/7index-pack: report correct bad object offsets even if they are largebuiltin/index-pack.c+4 -30 replies
5/7index-pack: correct "offset" type in unpack_entry_data()builtin/index-pack.c+1 -10 replies
6/7pack-objects: do not truncate result in-pack object size on 32-bit systemsbuiltin/pack-objects.c+8 -70 replies
7/7fsck: use streaming interface for large blobs in packbuiltin/fsck.c pack-check.c pack.h +1 more+29 -60 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by.

PatchChristoph Michelbach
1/7Noticed-by
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/7] Number truncation with 4+ GB files on 32-bit systems

A diff from nd/pack-ofs-4gb-limit can explain the changes better than me.

I did not add PRIdMAX or similar because that carries a risk to exotic platforms that people rarely test. Just casting to unsigned should be fine.

builtin/fsck.c +4 -0
index 55eac75..b08bc8b 100644
@@ -356,6 +356,10 @@ static int fsck_sha1(const unsigned char *sha1)
 static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,
 			   unsigned long size, void *buffer, int *eaten)
 {
+	/*
+	 * Note, buffer may be NULL if type is OBJ_BLOB. See
+	 * verify_packfile(), data_valid variable for details.
+	 */
 	struct object *obj;
 	obj = parse_object_buffer(sha1, type, size, buffer, eaten);
 	if (!obj) {
pack-check.c +2 -1
index 14e8cb0..d123846 100644
@@ -106,7 +106,7 @@ static int verify_packfile(struct packed_git *p,
 		enum object_type type;
 		unsigned long size;
 		off_t curpos;
-		int data_valid = 0;
+		int data_valid;
 
 		if (p->index_version > 1) {
 			off_t offset = entries[i].offset;
@@ -130,6 +130,7 @@ static int verify_packfile(struct packed_git *p,
 			 * the data in-core only to discard.
 			 */
 			data = NULL;
+			data_valid = 0;
 		} else {
 			data = unpack_entry(p, entries[i].offset, &type, &size);
 			data_valid = 1;
t/t1050-large.sh +3 -4
index f9f3d13..096dbff 100755
@@ -177,10 +177,9 @@ test_expect_success 'zip achiving, deflate' '
 	git archive --format=zip HEAD >/dev/null
 '
 
-test_expect_success 'fsck' '
-	test_must_fail git fsck 2>err &&
-	n=$(grep "error: attempting to allocate .* over limit" err | wc -l) &&
-	test "$n" -gt 1
+test_expect_success 'fsck large blobs' '
+	git fsck 2>err &&
+	test_must_be_empty err
 '
 
 test_done

Nguyễn Thái Ngọc Duy (7):
pack-objects: pass length to check_pack_crc() without truncation sha1_file.c: use type off_t* for object_info->disk_sizep
index-pack: correct "len" type in unpack_data()
index-pack: report correct bad object offsets even if they are large
index-pack: correct "offset" type in unpack_entry_data()
pack-objects: do not truncate result in-pack object size on 32-bit systems
fsck: use streaming interface for large blobs in pack

 builtin/cat-file.c     |  4 ++--
 builtin/fsck.c         |  4 ++++
 builtin/index-pack.c   | 23 ++++++++++++-----------
 builtin/pack-objects.c | 17 +++++++++--------
 cache.h                |  2 +-
 pack-check.c           | 23 +++++++++++++++++++++--
 pack.h                 |  1 +
 sha1_file.c            |  2 +-
 t/t1050-large.sh       |  7 +++----
 9 files changed, 54 insertions(+), 29 deletions(-)
Signature · 1 line
2.9.1.564.gb2f7278