]> granicus.if.org Git - git/commitdiff
unpack-objects: call fsck_finish() after fscking objects
authorJeff King <peff@peff.net>
Fri, 4 May 2018 23:40:08 +0000 (19:40 -0400)
committerJeff King <peff@peff.net>
Tue, 22 May 2018 03:55:12 +0000 (23:55 -0400)
As with the previous commit, we must call fsck's "finish"
function in order to catch any queued objects for
.gitmodules checks.

This second pass will be able to access any incoming
objects, because we will have exploded them to loose objects
by now.

This isn't quite ideal, because it means that bad objects
may have been written to the object database (and a
subsequent operation could then reference them, even if the
other side doesn't send the objects again). However, this is
sufficient when used with receive.fsckObjects, since those
loose objects will all be placed in a temporary quarantine
area that will get wiped if we find any problems.

Signed-off-by: Jeff King <peff@peff.net>
builtin/unpack-objects.c
t/t7415-submodule-names.sh

index 648b952ab00821b28422d7e225c910a24027754f..c8f1406d2340c5cf2c1ac775039e32a244fede33 100644 (file)
@@ -572,8 +572,11 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
        unpack_all();
        the_hash_algo->update_fn(&ctx, buffer, offset);
        the_hash_algo->final_fn(oid.hash, &ctx);
-       if (strict)
+       if (strict) {
                write_rest();
+               if (fsck_finish(&fsck_options))
+                       die(_("fsck error in pack objects"));
+       }
        if (hashcmp(fill(the_hash_algo->rawsz), oid.hash))
                die("final sha1 did not match");
        use(the_hash_algo->rawsz);
index c8ce2f4717f3305c4b82914deab894d849e25836..7fdf5d68bd4ee9b3b57a601047cb4c7e1b3f790f 100755 (executable)
@@ -77,4 +77,11 @@ test_expect_success 'fsck detects evil superproject' '
        test_must_fail git fsck
 '
 
+test_expect_success 'transfer.fsckObjects detects evil superproject (unpack)' '
+       rm -rf dst.git &&
+       git init --bare dst.git &&
+       git -C dst.git config transfer.fsckObjects true &&
+       test_must_fail git push dst.git HEAD
+'
+
 test_done