aboutsummaryrefslogtreecommitdiff
path: root/libssh/wrapper.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2008-03-06 21:46:23 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2008-03-06 21:46:23 +0000
commit5029fe9d74d0fbc93cc2756d8b48d1bb462e3f39 (patch)
tree7f2e47f740cf7deb54874f1b25ee7ae1c1f17650 /libssh/wrapper.c
parent8e04bf0ef1c84e3c05551f640f8b8ac9b0dc9d50 (diff)
downloadlibssh-5029fe9d74d0fbc93cc2756d8b48d1bb462e3f39.tar.gz
libssh-5029fe9d74d0fbc93cc2756d8b48d1bb462e3f39.tar.xz
libssh-5029fe9d74d0fbc93cc2756d8b48d1bb462e3f39.zip
Merged Keisial bugfix (crash when available protocols mismatch)
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@140 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/wrapper.c')
-rw-r--r--libssh/wrapper.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/libssh/wrapper.c b/libssh/wrapper.c
index f72adaa1..366455d2 100644
--- a/libssh/wrapper.c
+++ b/libssh/wrapper.c
@@ -463,8 +463,8 @@ static int crypt_set_algorithms2(SSH_SESSION *session){
while(ssh_ciphertab[i].name && strcmp(wanted,ssh_ciphertab[i].name))
i++;
if(!ssh_ciphertab[i].name){
- ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms : no crypto algorithm function found for %s",wanted);
- return -1;
+ ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms2 : no crypto algorithm function found for %s",wanted);
+ return SSH_ERROR;
}
ssh_say(2,"Set output algorithm %s\n",wanted);
session->next_crypto->out_cipher=cipher_new(i);
@@ -475,7 +475,7 @@ static int crypt_set_algorithms2(SSH_SESSION *session){
i++;
if(!ssh_ciphertab[i].name){
ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms : no crypto algorithm function found for %s",wanted);
- return -1;
+ return SSH_ERROR;
}
ssh_say(2,"Set input algorithm %s\n",wanted);
session->next_crypto->in_cipher=cipher_new(i);
@@ -484,7 +484,7 @@ static int crypt_set_algorithms2(SSH_SESSION *session){
session->next_crypto->do_compress_out=1;
if(strstr(session->client_kex.methods[SSH_COMP_S_C],"zlib"))
session->next_crypto->do_compress_in=1;
- return 0;
+ return SSH_OK;
}
static int crypt_set_algorithms1(SSH_SESSION *session){
@@ -498,7 +498,7 @@ static int crypt_set_algorithms1(SSH_SESSION *session){
}
session->next_crypto->out_cipher=cipher_new(i);
session->next_crypto->in_cipher=cipher_new(i);
- return 0;
+ return SSH_OK;
}
int crypt_set_algorithms(SSH_SESSION *session){
@@ -506,6 +506,7 @@ int crypt_set_algorithms(SSH_SESSION *session){
crypt_set_algorithms2(session);
}
+// TODO Obviously too much cut and paste here
int crypt_set_algorithms_server(SSH_SESSION *session){
/* we must scan the kex entries to find crypto algorithms and set their appropriate structure */
int i=0;
@@ -513,11 +514,15 @@ int crypt_set_algorithms_server(SSH_SESSION *session){
char *server=session->server_kex.methods[SSH_CRYPT_S_C];
char *client=session->client_kex.methods[SSH_CRYPT_S_C];
char *match=ssh_find_matching(client,server);
+ if(!match){
+ ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms_server : no matching algorithm function found for %s",server);
+ return SSH_ERROR;
+ }
while(ssh_ciphertab[i].name && strcmp(match,ssh_ciphertab[i].name))
i++;
if(!ssh_ciphertab[i].name){
- ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms : no crypto algorithm function found for %s",server);
- return -1;
+ ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms_server : no crypto algorithm function found for %s",server);
+ return SSH_ERROR;
}
ssh_say(2,"Set output algorithm %s\n",match);
session->next_crypto->out_cipher=cipher_new(i);
@@ -525,12 +530,16 @@ int crypt_set_algorithms_server(SSH_SESSION *session){
/* in */
client=session->client_kex.methods[SSH_CRYPT_C_S];
server=session->server_kex.methods[SSH_CRYPT_S_C];
- match=ssh_find_matching(client,server);
+ match=ssh_find_matching(client,server);
+ if(!match){
+ ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms_server : no matching algorithm function found for %s",server);
+ return SSH_ERROR;
+ }
while(ssh_ciphertab[i].name && strcmp(match,ssh_ciphertab[i].name))
i++;
if(!ssh_ciphertab[i].name){
- ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms : no crypto algorithm function found for %s",server);
- return -1;
+ ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms_server : no crypto algorithm function found for %s",server);
+ return SSH_ERROR;
}
ssh_say(2,"Set input algorithm %s\n",match);
session->next_crypto->in_cipher=cipher_new(i);
@@ -560,7 +569,7 @@ int crypt_set_algorithms_server(SSH_SESSION *session){
session->hostkeys=TYPE_RSA;
else {
ssh_set_error(session,SSH_FATAL,"cannot know what %s is into %s",match,server);
- return -1;
+ return SSH_ERROR;
}
- return 0;
+ return SSH_OK;
}