vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Dmitry Belyavskiy 745da7
diff --git a/compat.c b/compat.c
Dmitry Belyavskiy 745da7
index 46dfe3a9c2e..478a9403eea 100644
Dmitry Belyavskiy 745da7
--- a/compat.c
Dmitry Belyavskiy 745da7
+++ b/compat.c
Dmitry Belyavskiy 745da7
@@ -190,26 +190,26 @@ compat_pkalg_proposal(struct ssh *ssh, char *pkalg_prop)
Dmitry Belyavskiy 745da7
 char *
Dmitry Belyavskiy 745da7
 compat_kex_proposal(struct ssh *ssh, char *p)
Dmitry Belyavskiy 745da7
 {
Dmitry Belyavskiy 745da7
-	char *cp = NULL;
Dmitry Belyavskiy 745da7
+	char *cp = NULL, *cp2 = NULL;
Dmitry Belyavskiy 745da7
 
Dmitry Belyavskiy 745da7
 	if ((ssh->compat & (SSH_BUG_CURVE25519PAD|SSH_OLD_DHGEX)) == 0)
Dmitry Belyavskiy 745da7
 		return xstrdup(p);
Dmitry Belyavskiy 745da7
 	debug2_f("original KEX proposal: %s", p);
Dmitry Belyavskiy 745da7
 	if ((ssh->compat & SSH_BUG_CURVE25519PAD) != 0)
Dmitry Belyavskiy 745da7
-		if ((p = match_filter_denylist(p,
Dmitry Belyavskiy 745da7
+		if ((cp = match_filter_denylist(p,
Dmitry Belyavskiy 745da7
 		    "curve25519-sha256@libssh.org")) == NULL)
Dmitry Belyavskiy 745da7
 			fatal("match_filter_denylist failed");
Dmitry Belyavskiy 745da7
 	if ((ssh->compat & SSH_OLD_DHGEX) != 0) {
Dmitry Belyavskiy 745da7
-		cp = p;
Dmitry Belyavskiy 745da7
-		if ((p = match_filter_denylist(p,
Dmitry Belyavskiy 745da7
+		if ((cp2 = match_filter_denylist(cp ? cp : p,
Dmitry Belyavskiy 745da7
 		    "diffie-hellman-group-exchange-sha256,"
Dmitry Belyavskiy 745da7
 		    "diffie-hellman-group-exchange-sha1")) == NULL)
Dmitry Belyavskiy 745da7
 			fatal("match_filter_denylist failed");
Dmitry Belyavskiy 745da7
 		free(cp);
Dmitry Belyavskiy 745da7
+		cp = cp2;
Dmitry Belyavskiy 745da7
 	}
Dmitry Belyavskiy 745da7
-	debug2_f("compat KEX proposal: %s", p);
Dmitry Belyavskiy 745da7
-	if (*p == '\0')
Dmitry Belyavskiy 745da7
+	if (cp == NULL || *cp == '\0')
Dmitry Belyavskiy 745da7
 		fatal("No supported key exchange algorithms found");
Dmitry Belyavskiy 745da7
-	return p;
Dmitry Belyavskiy 745da7
+	debug2_f("compat KEX proposal: %s", cp);
Dmitry Belyavskiy 745da7
+	return cp;
Dmitry Belyavskiy 745da7
 }
Dmitry Belyavskiy 745da7