From 8d90bbfc285eba2d20378338a4d784179fd51d98 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Mon, 16 May 2005 17:16:25 +0000 Subject: [PATCH] Fix segfault when client/host can't agree on hostkey/crypt/mac/comp --- README | 2 ++ src/kex.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README b/README index 6dd8ff22..c094c144 100644 --- a/README +++ b/README @@ -12,6 +12,8 @@ Version 0.10 (Re)Fixed SFTP INIT to send the correct SFTP packet length. + Fixed segfault when client and host can't agree on a hostkey/crypt/mac/comp method. (Thanks puudeli) + Version 0.9 ----------- diff --git a/src/kex.c b/src/kex.c index d58b3f65..618705d7 100644 --- a/src/kex.c +++ b/src/kex.c @@ -928,7 +928,7 @@ static int libssh2_kex_agree_hostkey(LIBSSH2_SESSION *session, unsigned long kex return -1; } - while ((*hostkeyp)->name) { + while (hostkeyp && (*hostkeyp)->name) { s = libssh2_kex_agree_instr(hostkey, hostkey_len, (*hostkeyp)->name, strlen((*hostkeyp)->name)); if (s) { /* So far so good, but does it suit our purposes? (Encrypting vs Signing) */ @@ -1036,7 +1036,7 @@ static int libssh2_kex_agree_crypt(LIBSSH2_SESSION *session, libssh2_endpoint_da return -1; } - while ((*cryptp)->name) { + while (*cryptp && (*cryptp)->name) { s = libssh2_kex_agree_instr(crypt, crypt_len, (*cryptp)->name, strlen((*cryptp)->name)); if (s) { endpoint->crypt = *cryptp; @@ -1081,7 +1081,7 @@ static int libssh2_kex_agree_mac(LIBSSH2_SESSION *session, libssh2_endpoint_data return -1; } - while ((*macp)->name) { + while (*macp && (*macp)->name) { s = libssh2_kex_agree_instr(mac, mac_len, (*macp)->name, strlen((*macp)->name)); if (s) { endpoint->mac = *macp; @@ -1126,7 +1126,7 @@ static int libssh2_kex_agree_comp(LIBSSH2_SESSION *session, libssh2_endpoint_dat return -1; } - while ((*compp)->name) { + while (*compp && (*compp)->name) { s = libssh2_kex_agree_instr(comp, comp_len, (*compp)->name, strlen((*compp)->name)); if (s) { endpoint->comp = *compp;