1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-10 22:26:08 +02:00

gpg-interface: avoid buffer overrun in parse_ssh_output()

If the string "key" we found in the output of ssh-keygen happens to be
located at the very end of the line, then going four characters further
leaves us beyond the end of the string.  Explicitly search for the
space after "key" to handle a missing one gracefully.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2021-10-30 19:07:38 +02:00 committed by Junio C Hamano
parent 18b18503e3
commit 65db97b4fa

View File

@ -409,9 +409,9 @@ static void parse_ssh_output(struct signature_check *sigc)
goto cleanup;
}
key = strstr(line, "key");
key = strstr(line, "key ");
if (key) {
sigc->fingerprint = xstrdup(strstr(line, "key") + 4);
sigc->fingerprint = xstrdup(strstr(line, "key ") + 4);
sigc->key = xstrdup(sigc->fingerprint);
} else {
/*