Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-10-30 20:07:38 +0300
committerJunio C Hamano <gitster@pobox.com>2021-11-02 03:00:41 +0300
commit65db97b4fa6b03059f2f14f313e07ca799d4ef3f (patch)
treebb94834a937d98134fc36d883220ad33c21874a6 /gpg-interface.c
parent18b18503e3b3721e0a513cbc83971a960e944c19 (diff)
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>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index 62d340e78a..3838536f0a 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -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 {
/*