aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-09-01 16:05:06 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-09-01 16:05:06 +0200
commite67d834156a381fe7ef7933d135130083b86d1e3 (patch)
treee8f3485bc07f19cc2f2bef6ad0ef11af0606984d /libssh
parenta93f2d8bfe98e2927fc7024973c52062ccd28b30 (diff)
downloadlibssh-e67d834156a381fe7ef7933d135130083b86d1e3.tar.gz
libssh-e67d834156a381fe7ef7933d135130083b86d1e3.tar.xz
libssh-e67d834156a381fe7ef7933d135130083b86d1e3.zip
Fix initialization of threading
Diffstat (limited to 'libssh')
-rw-r--r--libssh/client.c3
-rw-r--r--libssh/dh.c3
-rw-r--r--libssh/init.c1
-rw-r--r--libssh/keyfiles.c6
-rw-r--r--libssh/threads.c12
5 files changed, 19 insertions, 6 deletions
diff --git a/libssh/client.c b/libssh/client.c
index 749284f..d12aa11 100644
--- a/libssh/client.c
+++ b/libssh/client.c
@@ -701,10 +701,11 @@ int ssh_connect(ssh_session session) {
/*, session->timeout * 1000 + session->timeout_usec); */
}
- if (ret != SSH_OK) {
+ if (ret == SSH_ERROR) {
leave_function();
return SSH_ERROR;
}
+
set_status(session, 0.2f);
session->alive = 1;
diff --git a/libssh/dh.c b/libssh/dh.c
index eff74bf..74d799e 100644
--- a/libssh/dh.c
+++ b/libssh/dh.c
@@ -55,7 +55,6 @@
#include "libssh/session.h"
#include "libssh/keys.h"
#include "libssh/dh.h"
-#include "libssh/threads.h"
/* todo: remove it */
#include "libssh/string.h"
@@ -156,7 +155,7 @@ void ssh_crypto_finalize(void) {
bignum_free(p);
p = NULL;
ssh_crypto_initialized=0;
- ssh_threads_finalize();
+
}
}
diff --git a/libssh/init.c b/libssh/init.c
index d8e7722..5952e27 100644
--- a/libssh/init.c
+++ b/libssh/init.c
@@ -73,6 +73,7 @@ int ssh_init(void) {
@returns 0 otherwise
*/
int ssh_finalize(void) {
+ ssh_threads_finalize();
ssh_free_global_poll_ctx();
ssh_regex_finalize();
ssh_crypto_finalize();
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index 0378279..9512de0 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -1615,6 +1615,12 @@ int ssh_is_server_known(ssh_session session) {
return SSH_SERVER_ERROR;
}
+ if (session->current_crypto == NULL){
+ ssh_set_error(session, SSH_FATAL,
+ "ssh_is_host_known called without cryptographic context");
+ leave_function();
+ return SSH_SERVER_ERROR;
+ }
host = ssh_lowercase(session->host);
hostport = ssh_hostport(host,session->port);
if (host == NULL || hostport == NULL) {
diff --git a/libssh/threads.c b/libssh/threads.c
index 63e9d83..087b56c 100644
--- a/libssh/threads.c
+++ b/libssh/threads.c
@@ -153,6 +153,10 @@ static void libcrypto_thread_finalize(){
*/
int ssh_threads_init(void){
+ static int threads_initialized=0;
+ int ret;
+ if(threads_initialized)
+ return SSH_OK;
/* first initialize the user_callbacks with our default handlers if not
* already the case
*/
@@ -166,11 +170,13 @@ int ssh_threads_init(void){
/* Then initialize the crypto libraries threading callbacks */
#ifdef HAVE_LIBGCRYPT
- return libgcrypt_thread_init();
+ ret = libgcrypt_thread_init();
#else /* Libcrypto */
- return libcrypto_thread_init();
+ ret = libcrypto_thread_init();
#endif
- return SSH_ERROR;
+ if(ret == SSH_OK)
+ threads_initialized=1;
+ return ret;
}
void ssh_threads_finalize(void){