Skip to content

Commit 65db97b

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Acked-by: Fabian Stelzer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 18b1850 commit 65db97b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gpg-interface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ static void parse_ssh_output(struct signature_check *sigc)
409409
goto cleanup;
410410
}
411411

412-
key = strstr(line, "key");
412+
key = strstr(line, "key ");
413413
if (key) {
414-
sigc->fingerprint = xstrdup(strstr(line, "key") + 4);
414+
sigc->fingerprint = xstrdup(strstr(line, "key ") + 4);
415415
sigc->key = xstrdup(sigc->fingerprint);
416416
} else {
417417
/*

0 commit comments

Comments
 (0)