git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] verify_pack: do not ignore return value of verification function
@ 2015-11-30 22:47 David Turner
  2015-12-01 23:28 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: David Turner @ 2015-11-30 22:47 UTC (permalink / raw)
  To: git, peff; +Cc: 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.

Signed-off-by: David Turner <dturner@twopensource.com>
---
 pack-check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pack-check.c b/pack-check.c
index 63a595c..433bd86 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -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;
 		}
-- 
2.4.2.736.g391bb05-twtrsrc

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] verify_pack: do not ignore return value of verification function
  2015-11-30 22:47 [PATCH] verify_pack: do not ignore return value of verification function David Turner
@ 2015-12-01 23:28 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2015-12-01 23:28 UTC (permalink / raw)
  To: David Turner; +Cc: git

On Mon, Nov 30, 2015 at 05:47:42PM -0500, David Turner wrote:

> 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>
> ---
>  pack-check.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, this looks good to me.

-Peff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-01 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-30 22:47 [PATCH] verify_pack: do not ignore return value of verification function David Turner
2015-12-01 23:28 ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).