From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Michael V. Scovetta" <michael.scovetta@gmail.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
git@vger.kernel.org
Subject: Re: [PATCH] sequencer: detect author name errors in read_author_script()
Date: Mon, 03 Oct 2022 09:34:26 -0700 [thread overview]
Message-ID: <xmqq8rlwx3vx.fsf@gitster.g> (raw)
In-Reply-To: <YzqhEcTDwMwa8dQX@coredump.intra.peff.net> (Jeff King's message of "Mon, 3 Oct 2022 04:45:05 -0400")
Jeff King <peff@peff.net> writes:
> On Sun, Oct 02, 2022 at 11:39:16PM -0700, Michael V. Scovetta wrote:
>
>> In commit 2a7d63a2, sequencer.c:912 looks like:
>> 912 if (name_i == -2)
>> 913 error(_("missing 'GIT_AUTHOR_NAME'"));
>> 914 if (email_i == -2)
>> 915 error(_("missing 'GIT_AUTHOR_EMAIL'"));
>> 916 if (date_i == -2)
>> 917 error(_("missing 'GIT_AUTHOR_DATE'"));
>> 918 if (date_i < 0 || email_i < 0 || date_i < 0 || err) <-- date_i
>> is referenced here twice
>> 919 goto finish;
>>
>> I'm fairly sure that line 918 should be:
>> 918 if (name_i < 0 || email_i < 0 || date_i < 0 || err)
>
> Agreed, but +cc Phillip as the original author.
>
>> I haven't validated this, but I suspect that if
>> `rebase-merge/author-script` contained two GIT_AUTHOR_NAME fields,
>> then name_i would be set to -1 (by the error function), but control
>> wouldn't flow to finish, but instead to line 920 ( *name =
>> kv.items[name_i].util; ) where it would attempt to access memory
>> slightly outside of items' memory space.
>
> Correct. It also happens if GIT_AUTHOR_NAME is missing.
>
>> I haven't been able to actually trigger the bug, but strongly suspect
>> I'm just not familiar enough with how rebasing works under the covers.
>
> It's a little tricky, because we avoid writing and reading the
> author-script file unless necessary. An easy way to need it is to break
> with a conflict (which writes it), and then resume with "git rebase
> --continue" (which reads it back while committing).
>
> Here's a patch to fix it. Thanks for your report!
And thanks for your fix ;-)
next prev parent reply other threads:[~2022-10-03 16:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-03 6:39 Bug Report: Duplicate condition in read_author_script (sequencer.c) Michael V. Scovetta
2022-10-03 8:45 ` [PATCH] sequencer: detect author name errors in read_author_script() Jeff King
2022-10-03 9:29 ` Phillip Wood
2022-10-03 17:15 ` Jeff King
2022-10-03 9:40 ` Ævar Arnfjörð Bjarmason
2022-10-03 17:27 ` Jeff King
2022-10-03 17:39 ` Jeff King
2022-10-03 18:05 ` Junio C Hamano
2022-10-03 16:34 ` Junio C Hamano [this message]
2022-10-03 17:35 ` Jeff King
2022-10-03 18:07 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq8rlwx3vx.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=michael.scovetta@gmail.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.