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

2016-07-13 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy   writes:

> 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.

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


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

2016-07-13 Thread Nguyễn Thái Ngọc Duy
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.

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 55eac75..b08bc8b 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -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) {
diff --git a/pack-check.c b/pack-check.c
index 14e8cb0..d123846 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -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;
diff --git a/t/t1050-large.sh b/t/t1050-large.sh
index f9f3d13..096dbff 100755
--- a/t/t1050-large.sh
+++ b/t/t1050-large.sh
@@ -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(-)

-- 
2.9.1.564.gb2f7278

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