git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: David Emett <dave@sp4m.net>
Cc: git@vger.kernel.org
Subject: [PATCH v2 1/2] pack-bitmap: clean up include_check after use
Date: Wed, 28 Apr 2021 11:42:30 -0400	[thread overview]
Message-ID: <YImCZpLA0TjAkU9/@coredump.intra.peff.net> (raw)
In-Reply-To: <YImCNXC5DUvy5gT8@coredump.intra.peff.net>

When a bitmap walk has to traverse (to fill in non-bitmapped objects),
we use rev_info's include_check mechanism to let us stop the traversal
early. But after setting the function and its data parameter, we never
clean it up. This means that if the rev_info is used for a subsequent
traversal without bitmaps, it will unexpectedly call into our
include_check function (worse, it will do so pointing to a now-defunct
stack variable in include_check_data, likely resulting in a segfault).

There's no code which does this now, but it's an accident waiting to
happen. Let's clean up after ourselves in the bitmap code.

Reported-by: David Emett <dave@sp4m.net>
Signed-off-by: Jeff King <peff@peff.net>
---
 pack-bitmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pack-bitmap.c b/pack-bitmap.c
index 3ed15431cd..f2b59fbf48 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -631,6 +631,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
 		traverse_commit_list_filtered(filter, revs,
 					      show_commit, show_object,
 					      &show_data, NULL);
+
+		revs->include_check = NULL;
+		revs->include_check_data = NULL;
 	}
 
 	return base;
-- 
@@ -631,6 +631,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
 		traverse_commit_list_filtered(filter, revs,
 					      show_commit, show_object,
 					      &show_data, NULL);
+
+		revs->include_check = NULL;
+		revs->include_check_data = NULL;
 	}
 
 	return base;
-- 
2.31.1.791.g8400859cdc


  reply	other threads:[~2021-04-28 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 10:45 Two issues with mark_reachable_objects David Emett
2021-04-27 14:41 ` Jeff King
2021-04-27 15:13   ` Jeff King
2021-04-27 15:43 ` [PATCH] prune: save reachable-from-recent objects with bitmaps Jeff King
2021-04-28 12:20   ` David Emett
2021-04-28 15:13     ` Jeff King
2021-04-28 15:41       ` [PATCH v2 0/2] " Jeff King
2021-04-28 15:42         ` Jeff King [this message]
2021-04-28 15:42         ` [PATCH v2 2/2] " Jeff King
2021-04-29  1:37           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YImCZpLA0TjAkU9/@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=dave@sp4m.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).