Git development
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Kushal Das <kushal@sunet.se>
Cc: git@vger.kernel.org
Subject: Re: [BUG] v2.45+: git commit -S invalidates signature for non-UTF-8 messages
Date: Mon, 20 Apr 2026 22:11:11 +0000	[thread overview]
Message-ID: <aeakf0xcjSteTMZp@fruit.crustytoothpaste.net> (raw)
In-Reply-To: <4d5d04e2-49c4-4781-a289-f8cf79570643@sunet.se>

[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]

On 2026-04-20 at 08:59:05, Kushal Das wrote:
> Hi all,
> 
> Every `git commit -S` since v2.45.0 produces a permanently-BAD
> signature when the commit message contains bytes that are not valid
> UTF-8 AND `i18n.commitEncoding` is unset (i.e. the default case).
> Verification fails under both `gpg --verify` and any non-GnuPG signer.
> The failure is deterministic: it happens every time, on every
> non-UTF-8 commit, no card or external tooling needed.

I'm not sure that's a valid configuration.  The commit message either
needs to be UTF-8 or you need to declare the encoding so Git can convert
it.

> My best guess is commit 6206089cbd0b1cb30a017ec904567f040ab4cea0 starting
> this (and I am maybe 100% wrong in identifying the cause).

It does bisect to that commit.  I wrote that patch originally, but it
got modified and sent upstream by someone else.  I'm not sure where it
got introduced, though.

> In pre-6206089cbd `commit_tree_extended`, `verify_utf8(&buffer)` ran
> BEFORE `sign_with_header(&buffer, sign_commit)`. `verify_utf8` is not
> a simple validator -- it mutates the strbuf in place, replacing
> invalid-UTF-8 bytes with their Latin-1 -> UTF-8 two-byte form. The
> signer therefore saw the transcoded bytes, and the same transcoded
> bytes were then written to the object database. Signer and
> verifier agreed.

The fact that we have a function called `verify_utf8` that does more
than verify is a problem.  I'll send out a two-patch series in a minute
or two that first fixes that to be called `ensure_utf8` and then fixes
the issue.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 325 bytes --]

  reply	other threads:[~2026-04-20 22:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20  8:59 [BUG] v2.45+: git commit -S invalidates signature for non-UTF-8 messages Kushal Das
2026-04-20 22:11 ` brian m. carlson [this message]
2026-04-20 22:14   ` [PATCH 1/2] commit: name UTF-8 function appropriately brian m. carlson
2026-04-20 22:14     ` [PATCH 2/2] commit: sign commit after mutating buffer brian m. carlson
2026-04-22 15:10       ` Elijah Newren
2026-04-24 20:17         ` brian m. carlson
2026-04-22 15:10     ` [PATCH 1/2] commit: name UTF-8 function appropriately Elijah Newren
2026-04-21  7:39   ` [BUG] v2.45+: git commit -S invalidates signature for non-UTF-8 messages Kushal Das
2026-04-21 22:13     ` brian m. carlson
2026-04-22 18:13   ` D. Ben Knoble
2026-04-27 22:18   ` [PATCH v2 1/2] commit: name UTF-8 function appropriately brian m. carlson
2026-04-27 22:18     ` [PATCH v2 2/2] commit: sign commit after mutating buffer brian m. carlson
2026-05-12  5:54       ` 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=aeakf0xcjSteTMZp@fruit.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=kushal@sunet.se \
    /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