diff options
author | dtucker@openbsd.org <dtucker@openbsd.org> | 2022-06-24 06:37:00 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-06-27 23:43:15 +0200 |
commit | 646686136c34c2dbf6a01296dfaa9ebee029386d (patch) | |
tree | e6e828e598bffa975e5615b58a03adafa0808338 /sshconnect2.c | |
parent | Zero out LIBFIDO2 when SK support not usable. (diff) | |
download | openssh-646686136c34c2dbf6a01296dfaa9ebee029386d.tar.xz openssh-646686136c34c2dbf6a01296dfaa9ebee029386d.zip |
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 'sshconnect2.c')
-rw-r--r-- | sshconnect2.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sshconnect2.c b/sshconnect2.c index b25225e64..583d292b3 100644 --- a/sshconnect2.c +++ b/sshconnect2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect2.c,v 1.356 2022/02/01 23:32:51 djm Exp $ */ +/* $OpenBSD: sshconnect2.c,v 1.357 2022/06/24 04:37:00 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2008 Damien Miller. All rights reserved. @@ -114,6 +114,7 @@ first_alg(const char *algs) return ret; } +/* Returns an allocated string that the caller must free. */ static char * order_hostkeyalgs(char *host, struct sockaddr *hostaddr, u_short port, const struct ssh_conn_info *cinfo) @@ -217,7 +218,7 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port, const struct ssh_conn_info *cinfo) { char *myproposal[PROPOSAL_MAX] = { KEX_CLIENT }; - char *s, *all_key; + char *s, *all_key, *hostkeyalgs = NULL; int r, use_known_hosts_order = 0; xxx_host = host; @@ -255,9 +256,10 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port, myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs; if (use_known_hosts_order) { /* Query known_hosts and prefer algorithms that appear there */ + hostkeyalgs = order_hostkeyalgs(host, hostaddr, port, cinfo); myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = - compat_pkalg_proposal(ssh, - order_hostkeyalgs(host, hostaddr, port, cinfo)); + compat_pkalg_proposal(ssh, hostkeyalgs); + free(hostkeyalgs); } else { /* Use specified HostkeyAlgorithms exactly */ myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = |