summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-17 18:29:31 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-17 18:29:31 +0000
commit91afe0de8a5541c30146c54de64f2dafa33f2d04 (patch)
tree20ef68b08aaf30d040291b36549b4b728dc173d9
parente85b16ae49578cc8501b98c323c7658533478e81 (diff)
downloadlibssh-91afe0de8a5541c30146c54de64f2dafa33f2d04.tar.gz
libssh-91afe0de8a5541c30146c54de64f2dafa33f2d04.tar.xz
libssh-91afe0de8a5541c30146c54de64f2dafa33f2d04.zip
Revert commit 530.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@531 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r--libssh/dh.c14
-rw-r--r--libssh/keys.c5
2 files changed, 6 insertions, 13 deletions
diff --git a/libssh/dh.c b/libssh/dh.c
index bb22fcf..619a4d2 100644
--- a/libssh/dh.c
+++ b/libssh/dh.c
@@ -72,7 +72,7 @@ static unsigned char p_value[] = {
static unsigned long g_int = 2 ; /* G is defined as 2 by the ssh2 standards */
static bignum g;
static bignum p;
-static unsigned int ssh_crypto_initialized_ref_count = 0;
+static int ssh_crypto_inited=0;
int ssh_get_random(void *where, int len, int strong){
@@ -101,7 +101,7 @@ int ssh_get_random(void *where, int len, int strong){
* FIXME: Make the function thread safe by adding a semaphore or mutex.
*/
int ssh_crypto_init(void) {
- if (ssh_crypto_initialized_ref_count == 0) {
+ if (ssh_crypto_inited == 0) {
#ifdef HAVE_LIBGCRYPT
gcry_check_version(NULL);
@@ -134,23 +134,19 @@ int ssh_crypto_init(void) {
bignum_bin2bn(p_value, P_LEN, p);
OpenSSL_add_all_algorithms();
#endif
+ ssh_crypto_inited++;
}
- ssh_crypto_initialized_ref_count++;
-
return 0;
}
void ssh_crypto_finalize(void) {
- if (ssh_crypto_initialized_ref_count) {
- ssh_crypto_initialized_ref_count--;
- }
-
- if (ssh_crypto_initialized_ref_count == 0) {
+ if(ssh_crypto_inited) {
bignum_free(g);
g = NULL;
bignum_free(p);
p = NULL;
+ ssh_crypto_inited = 0;
}
}
diff --git a/libssh/keys.c b/libssh/keys.c
index d25cda3..04ddcd0 100644
--- a/libssh/keys.c
+++ b/libssh/keys.c
@@ -75,7 +75,6 @@ PUBLIC_KEY *publickey_make_dss(SSH_SESSION *session, BUFFER *buffer) {
key = malloc(sizeof(PUBLIC_KEY));
if (key == NULL) {
- buffer_free(buffer);
return NULL;
}
@@ -149,7 +148,7 @@ error:
string_free(pubkey);
publickey_free(key);
- return NULL;
+ return key;
}
PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer,
@@ -160,7 +159,6 @@ PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer,
key = malloc(sizeof(PUBLIC_KEY));
if (key == NULL) {
- buffer_free(buffer);
return NULL;
}
@@ -173,7 +171,6 @@ PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer,
key->type_c = type;
e = buffer_get_ssh_string(buffer);
n = buffer_get_ssh_string(buffer);
-
buffer_free(buffer); /* we don't need it anymore */
if(e == NULL || n == NULL) {