summaryrefslogtreecommitdiffstats
path: root/ssh-sk-helper.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-05-26 03:59:46 +0200
committerDamien Miller <djm@mindrot.org>2020-05-27 02:14:45 +0200
commit4be563994c0cbe9856e7dd3078909f41beae4a9c (patch)
tree84ad13c9f79894f9412eadae397a1656206b4395 /ssh-sk-helper.c
parentupstream: Restrict ssh-agent from signing web challenges for FIDO (diff)
downloadopenssh-4be563994c0cbe9856e7dd3078909f41beae4a9c.tar.xz
openssh-4be563994c0cbe9856e7dd3078909f41beae4a9c.zip
upstream: fix memleak of signature; from Pedro Martelletto
OpenBSD-Commit-ID: d0a6eb07e77c001427d738b220dd024ddc64b2bb
Diffstat (limited to 'ssh-sk-helper.c')
-rw-r--r--ssh-sk-helper.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ssh-sk-helper.c b/ssh-sk-helper.c
index 2f93ad716..8f92f4e23 100644
--- a/ssh-sk-helper.c
+++ b/ssh-sk-helper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-sk-helper.c,v 1.9 2020/01/25 23:13:09 djm Exp $ */
+/* $OpenBSD: ssh-sk-helper.c,v 1.10 2020/05/26 01:59:46 djm Exp $ */
/*
* Copyright (c) 2019 Google LLC
*
@@ -93,12 +93,12 @@ process_sign(struct sshbuf *req)
{
int r = SSH_ERR_INTERNAL_ERROR;
struct sshbuf *resp, *kbuf;
- struct sshkey *key;
+ struct sshkey *key = NULL;
uint32_t compat;
const u_char *message;
- u_char *sig;
- size_t msglen, siglen;
- char *provider, *pin;
+ u_char *sig = NULL;
+ size_t msglen, siglen = 0;
+ char *provider = NULL, *pin = NULL;
if ((r = sshbuf_froms(req, &kbuf)) != 0 ||
(r = sshbuf_get_cstring(req, &provider, NULL)) != 0 ||
@@ -134,8 +134,11 @@ process_sign(struct sshbuf *req)
(r = sshbuf_put_string(resp, sig, siglen)) != 0)
fatal("%s: buffer error: %s", __progname, ssh_err(r));
out:
+ sshkey_free(key);
sshbuf_free(kbuf);
free(provider);
+ if (sig != NULL)
+ freezero(sig, siglen);
if (pin != NULL)
freezero(pin, strlen(pin));
return resp;