Skip to content

Commit 2a635ed

Browse files
henning-schildgitster
authored andcommitted
gpg-interface: do not hardcode the key string len anymore
gnupg does print the keyid followed by a space and the signer comes next. The same pattern is also used in gpgsm, but there the key length would be 40 instead of 16. Instead of hardcoding the expected length, find the first space and calculate it. Input that does not match the expected format will be ignored now, before we jumped to found+17 which might have been behind the end of an unexpected string. Signed-off-by: Henning Schild <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac1f9bb commit 2a635ed

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gpg-interface.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ static void parse_gpg_output(struct signature_check *sigc)
8989
sigc->result = sigcheck_gpg_status[i].result;
9090
/* The trust messages are not followed by key/signer information */
9191
if (sigc->result != 'U') {
92-
sigc->key = xmemdupz(found, 16);
92+
next = strchrnul(found, ' ');
93+
sigc->key = xmemdupz(found, next - found);
9394
/* The ERRSIG message is not followed by signer information */
94-
if (sigc-> result != 'E') {
95-
found += 17;
95+
if (*next && sigc-> result != 'E') {
96+
found = next + 1;
9697
next = strchrnul(found, '\n');
9798
sigc->signer = xmemdupz(found, next - found);
9899
}

0 commit comments

Comments
 (0)