Skip to content

Commit 12da782

Browse files
committed
upstream: fix double-free caused by compat_kex_proposal(); bz3522
by dtucker@, ok me OpenBSD-Commit-ID: 2bfc37cd2d41f67dad64c17a64cf2cd3806a5c80
1 parent 79efd95 commit 12da782

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

compat.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: compat.c,v 1.120 2022/07/01 03:35:45 dtucker Exp $ */
1+
/* $OpenBSD: compat.c,v 1.121 2023/02/02 12:10:05 djm Exp $ */
22
/*
33
* Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
44
*
@@ -190,26 +190,26 @@ compat_pkalg_proposal(struct ssh *ssh, char *pkalg_prop)
190190
char *
191191
compat_kex_proposal(struct ssh *ssh, char *p)
192192
{
193-
char *cp = NULL;
193+
char *cp = NULL, *cp2 = NULL;
194194

195195
if ((ssh->compat & (SSH_BUG_CURVE25519PAD|SSH_OLD_DHGEX)) == 0)
196196
return xstrdup(p);
197197
debug2_f("original KEX proposal: %s", p);
198198
if ((ssh->compat & SSH_BUG_CURVE25519PAD) != 0)
199-
if ((p = match_filter_denylist(p,
199+
if ((cp = match_filter_denylist(p,
200200
"[email protected]")) == NULL)
201201
fatal("match_filter_denylist failed");
202202
if ((ssh->compat & SSH_OLD_DHGEX) != 0) {
203-
cp = p;
204-
if ((p = match_filter_denylist(p,
203+
if ((cp2 = match_filter_denylist(cp ? cp : p,
205204
"diffie-hellman-group-exchange-sha256,"
206205
"diffie-hellman-group-exchange-sha1")) == NULL)
207206
fatal("match_filter_denylist failed");
208207
free(cp);
208+
cp = cp2;
209209
}
210-
debug2_f("compat KEX proposal: %s", p);
211-
if (*p == '\0')
210+
if (cp == NULL || *cp == '\0')
212211
fatal("No supported key exchange algorithms found");
213-
return p;
212+
debug2_f("compat KEX proposal: %s", cp);
213+
return cp;
214214
}
215215

0 commit comments

Comments
 (0)