Skip to contentSkip to conversation

verify_pack: do not ignore return value of verification function

PATCH In review David Turner 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 verify_pack: do not ignore return value of verification function

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.

---
 pack-check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
pack-check.c +1 -1
index 63a595c..433bd86 100644
@@ -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;
 		}
Signature · 1 line
2.4.2.736.g391bb05-twtrsrc
#1 lore raw
Quoted 10 lines · David Turner

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.

Quoted 4 lines
---
 pack-check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, this looks good to me.

-Peff