git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Marcel Röthke" <marcel@roethke.info>
To: git@vger.kernel.org
Cc: "Marcel Röthke" <marcel@roethke.info>
Subject: [PATCH] rerere: fix crash in during clear
Date: Sun, 18 Feb 2024 12:49:36 +0100	[thread overview]
Message-ID: <20240218114936.1121077-1-marcel@roethke.info> (raw)

When rerere_clear is called, for instance when aborting a rebase, and
the current conflict does not have a pre or postimage recorded git
crashes with a SEGFAULT in has_rerere_resolution when accessing the
status member of struct rerere_dir. This happens because scan_rerere_dir
only allocates the status field in struct rerere_dir when a post or
preimage was found. In some cases a segfault may happen even if a post
or preimage was recorded if it was not for the variant of interest and
the number of the variant that is present is lower than the variant of
interest.

This patch solves this by making sure the status field is large enough
to accommodate for the variant of interest so it can be accesses without
checking if it is large enough.

An alternative solution would be to always check before accessing the
status field, but I think the chosen solution aligns better with the
assumptions made elsewhere in the code.

Signed-off-by: Marcel Röthke <marcel@roethke.info>
---
 rerere.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rerere.c b/rerere.c
index ca7e77ba68..3973ccce37 100644
--- a/rerere.c
+++ b/rerere.c
@@ -219,6 +219,9 @@ static void read_rr(struct repository *r, struct string_list *rr)
 		buf.buf[hexsz] = '\0';
 		id = new_rerere_id_hex(buf.buf);
 		id->variant = variant;
+		/* make sure id->collection->status has enough space
+		 * for the variant we are interested in */
+		fit_variant(id->collection, variant);
 		string_list_insert(rr, path)->util = id;
 	}
 	strbuf_release(&buf);
-- 
2.43.2



             reply	other threads:[~2024-02-18 12:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18 11:49 Marcel Röthke [this message]
2024-02-18 13:02 ` [PATCH] rerere: fix crash in during clear Kristoffer Haugsbakk
2024-02-18 19:38   ` Marcel Röthke
2024-02-18 19:46 ` [PATCH v2] rerere: fix crash " Marcel Röthke
2024-02-20  1:22   ` Junio C Hamano
2024-02-24 11:25     ` Marcel Röthke
2024-03-24 21:51       ` Junio C Hamano
2024-03-25 19:30         ` Marcel Röthke
2024-04-07 20:12         ` Marcel Röthke
2024-04-08 15:18           ` Junio C Hamano
2024-04-09 12:13   ` [PATCH v3] rerere: fix crashes due to unmatched opening conflict markers Marcel Röthke
2024-04-12 23:37     ` Junio C Hamano
2024-04-15 20:15     ` Junio C Hamano
2024-04-16 10:50       ` Marcel Röthke
2024-04-16 10:52     ` [PATCH v4] " Marcel Röthke

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=20240218114936.1121077-1-marcel@roethke.info \
    --to=marcel@roethke.info \
    --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).