OSDN Git Service

verify_pack: do not ignore return value of verification function
authorDavid Turner <dturner@twopensource.com>
Mon, 30 Nov 2015 22:47:42 +0000 (17:47 -0500)
committerJeff King <peff@peff.net>
Tue, 1 Dec 2015 23:19:35 +0000 (18:19 -0500)
In verify_pack, a caller-supplied verification function is called.
The function returns an int.  If that return value is non-zero,
verify_pack should fail.

The only caller of verify_pack is in builtin/fsck.c, whose verify_fn
returns a meaningful error code (which was then ignored).  Now, fsck
might return a different error code (with more detail).  This would
happen in the unlikely event that a commit or tree that is a valid git
object but not a valid instance of its type gets into a pack.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Jeff King <peff@peff.net>
pack-check.c

index 63a595c..433bd86 100644 (file)
@@ -126,7 +126,7 @@ static int verify_packfile(struct packed_git *p,
                                    sha1_to_hex(entries[i].sha1), p->pack_name);
                else if (fn) {
                        int eaten = 0;
-                       fn(entries[i].sha1, type, size, data, &eaten);
+                       err |= fn(entries[i].sha1, type, size, data, &eaten);
                        if (eaten)
                                data = NULL;
                }