aboutsummaryrefslogtreecommitdiff
path: root/libssh/server.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2005-08-25 13:44:26 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2005-08-25 13:44:26 +0000
commit35221f967ef5e9801c2496a7f10ced1408f9cd20 (patch)
treefea84b96f4de3b8fd67df8bf557efa89c42be050 /libssh/server.c
parent6c0503f6c68ba92638516257c9991bcfd660e41e (diff)
downloadlibssh-35221f967ef5e9801c2496a7f10ced1408f9cd20.tar.gz
libssh-35221f967ef5e9801c2496a7f10ced1408f9cd20.tar.xz
libssh-35221f967ef5e9801c2496a7f10ced1408f9cd20.zip
fixed server segfaults on exit (double frees)
sftp_server_init() git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@15 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/server.c')
-rw-r--r--libssh/server.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libssh/server.c b/libssh/server.c
index fb678755..a2d9d48f 100644
--- a/libssh/server.c
+++ b/libssh/server.c
@@ -175,16 +175,11 @@ int server_set_kex(SSH_SESSION * session) {
}
server->methods = malloc(10 * sizeof(char **));
for (i = 0; i < 10; i++) {
- if (!(wanted = options->wanted_methods[i]))
- wanted = supported_methods[i];
- server->methods[i] = wanted;
+ if (!(wanted = options->wanted_methods[i]))
+ wanted = supported_methods[i];
+ server->methods[i] = strdup(wanted);
printf("server->methods[%d]=%s\n",i,wanted);
}
- if (!server->methods[i]) {
- ssh_set_error(session, SSH_FATAL,
- "kex error : did not find algo");
- return -1;
- }
return 0;
}
@@ -222,7 +217,15 @@ static int dh_handshake_server(SSH_SESSION *session){
make_sessionid(session);
sign=ssh_sign_session_id(session,prv);
buffer_free(buf);
- private_key_free(prv);
+ /* free private keys as they should not be readable past this point */
+ if(session->rsa_key){
+ private_key_free(session->rsa_key);
+ session->rsa_key=NULL;
+ }
+ if(session->dsa_key){
+ private_key_free(session->dsa_key);
+ session->dsa_key=NULL;
+ }
buffer_add_u8(session->out_buffer,SSH2_MSG_KEXDH_REPLY);
buffer_add_ssh_string(session->out_buffer,pubkey);
buffer_add_ssh_string(session->out_buffer,f);