]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gpg-interface: simplify ssh fingerprint parsing
authorChristian Couder <christian.couder@gmail.com>
Thu, 30 Oct 2025 12:33:28 +0000 (13:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Oct 2025 14:06:58 +0000 (07:06 -0700)
In "gpg-interface.c", the 'parse_ssh_output()' function takes a
'struct signature_check *sigc' argument and populates many members of
this 'sigc' using information parsed from 'sigc->output' which
contains the ouput of an `ssh-keygen -Y ...` command that was used to
verify an SSH signature.

When it populates 'sigc->fingerprint' though, it uses
`xstrdup(strstr(line, "key ") + 4)` while `strstr(line, "key ")` has
already been computed a few lines above and is already available in
the `key` variable.

Let's simplify this.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gpg-interface.c

index 2f4f0e32cb3b4f1fa245de4e7822cffaa5a31c9d..91d1b58cb48d1e3597ab6a452c463c2558ced872 100644 (file)
@@ -443,7 +443,7 @@ static void parse_ssh_output(struct signature_check *sigc)
 
        key = strstr(line, "key ");
        if (key) {
-               sigc->fingerprint = xstrdup(strstr(line, "key ") + 4);
+               sigc->fingerprint = xstrdup(key + 4);
                sigc->key = xstrdup(sigc->fingerprint);
        } else {
                /*