1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

ssh_options_set_algo: ensure we only set known algorithms internally

That way, we will not fail later on key exchange phase when something
unknown is negotiated.

Fixes T37

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Nikos Mavrogiannopoulos
2017-08-24 16:28:39 +02:00
committed by Andreas Schneider
parent de35212789
commit 895055ab38
3 changed files with 81 additions and 7 deletions

View File

@@ -164,7 +164,10 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
int ssh_options_set_algo(ssh_session session, int algo,
const char *list) {
if (!ssh_verify_existing_algo(algo, list)) {
char *p = NULL;
p = ssh_keep_known_algos(algo, list);
if (p == NULL) {
ssh_set_error(session, SSH_REQUEST_DENIED,
"Setting method: no algorithm for method \"%s\" (%s)",
ssh_kex_get_description(algo), list);
@@ -172,11 +175,7 @@ int ssh_options_set_algo(ssh_session session, int algo,
}
SAFE_FREE(session->opts.wanted_methods[algo]);
session->opts.wanted_methods[algo] = strdup(list);
if (session->opts.wanted_methods[algo] == NULL) {
ssh_set_error_oom(session);
return -1;
}
session->opts.wanted_methods[algo] = p;
return 0;
}