summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2022-06-24 04:37:00 +0000
committerDamien Miller <djm@mindrot.org>2022-06-28 07:43:15 +1000
commit646686136c34c2dbf6a01296dfaa9ebee029386d (patch)
treee6e828e598bffa975e5615b58a03adafa0808338 /sshd.c
parent193c6d8d905dde836b628fc07a7b9cf2d347e2a3 (diff)
downloadopenssh-git-646686136c34c2dbf6a01296dfaa9ebee029386d.tar.gz
upstream: Don't leak the strings allocated by order_hostkeyalgs()
and list_hostkey_types() that are passed to compat_pkalg_proposal(). Part of github PR#324 from ZoltanFridrich, ok djm@ OpenBSD-Commit-ID: b2f6e5f60f2bba293b831654328a8a0035ef4a1b
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sshd.c b/sshd.c
index f494cdbb..747ba1f7 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshd.c,v 1.586 2022/06/17 01:00:03 dtucker Exp $ */
+/* $OpenBSD: sshd.c,v 1.587 2022/06/24 04:37:00 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -603,6 +603,7 @@ append_hostkey_type(struct sshbuf *b, const char *s)
fatal_fr(r, "sshbuf_putf");
}
+/* Returns an allocated string that the caller must free. */
static char *
list_hostkey_types(void)
{
@@ -2367,6 +2368,7 @@ static void
do_ssh2_kex(struct ssh *ssh)
{
char *myproposal[PROPOSAL_MAX] = { KEX_SERVER };
+ char *hostkey_types = NULL;
struct kex *kex;
int r;
@@ -2388,8 +2390,10 @@ do_ssh2_kex(struct ssh *ssh)
ssh_packet_set_rekey_limits(ssh, options.rekey_limit,
options.rekey_interval);
+ hostkey_types = list_hostkey_types();
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal(
- ssh, list_hostkey_types());
+ ssh, hostkey_types);
+ free(hostkey_types);
/* start key exchange */
if ((r = kex_setup(ssh, myproposal)) != 0)