From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: Christian Couder <christian.couder@gmail.com>,
git@vger.kernel.org, Elijah Newren <newren@gmail.com>,
Jeff King <peff@peff.net>,
"brian m . carlson" <sandals@crustytoothpaste.net>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH 2/2] fast-import: add '--signed-commits=<mode>' option
Date: Thu, 11 Sep 2025 09:55:12 -0700 [thread overview]
Message-ID: <xmqq4it9ornz.fsf@gitster.g> (raw)
In-Reply-To: <aMJm8rSOeQsO_qTG@pks.im> (Patrick Steinhardt's message of "Thu, 11 Sep 2025 08:06:42 +0200")
Patrick Steinhardt <ps@pks.im> writes:
>> +/* Process signatures (up to 2: one "sha1" and one "sha256") */
>
> Hm. Does "up to 2" indicate that the commit may have two signatures at
> once? If so...
>
>> +static void import_signature(struct signature_data *sig_sha1,
>> + struct signature_data *sig_sha256,
>> + const char *v)
>> +{
>> + struct signature_data sig = { NULL, NULL, STRBUF_INIT };
>> +
>> + parse_one_signature(&sig, v);
>> +
>> + if (!strcmp(sig.hash_algo, "sha1"))
>> + store_signature(sig_sha1, &sig, "SHA-1");
>> + else if (!strcmp(sig.hash_algo, "sha256"))
>> + store_signature(sig_sha256, &sig, "SHA-256");
>
> ... then the code here seems to indicate otherwise as you only parse
> either the "sha1" signature or the "sha256" signature, but never both.
Correct and not quite. The caller can call you twice in its loop.
But if the input was malformed and had two "sha1" (and no "sha256"),
this will not barf (as the original, so it is not a new bug).
In any case, I also found that "up to 2" comment somewhat strange.
It was more understandable back when it was near the loop, but not
here.
>> + else
>> + BUG("parse_one_signature() returned unknown hash algo");
>
> I think we should not label this a bug. It is feasible that we introduce
> a third hash algorithm in the future that we don't know to handle yet,
> but that would not be a programming bug but a normal error. So we should
> probably `die()` instead.
Good thinking.
next prev parent reply other threads:[~2025-09-11 16:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 8:08 [PATCH 0/2] fast-import: start controlling how commit signatures are handled Christian Couder
2025-09-10 8:08 ` [PATCH 1/2] gpg-interface: refactor 'enum sign_mode' parsing Christian Couder
2025-09-10 16:50 ` Junio C Hamano
2025-09-11 6:06 ` Patrick Steinhardt
2025-09-11 16:29 ` Junio C Hamano
2025-09-12 12:40 ` Christian Couder
2025-09-12 12:40 ` Christian Couder
2025-09-10 8:08 ` [PATCH 2/2] fast-import: add '--signed-commits=<mode>' option Christian Couder
2025-09-10 17:09 ` Junio C Hamano
2025-09-12 13:35 ` Christian Couder
2025-09-12 14:14 ` Junio C Hamano
2025-09-15 10:29 ` Christian Couder
2025-09-15 16:02 ` Junio C Hamano
2025-09-17 18:27 ` Christian Couder
2025-09-10 18:21 ` Junio C Hamano
2025-09-12 13:41 ` Christian Couder
2025-09-12 14:09 ` Junio C Hamano
2025-09-11 6:06 ` Patrick Steinhardt
2025-09-11 16:55 ` Junio C Hamano [this message]
2025-09-12 13:47 ` Christian Couder
2025-09-12 13:25 ` Christian Couder
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=xmqq4it9ornz.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
/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 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 NNTP newsgroup(s).