[git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-22-g38fcd59

by Marcus Brinkmann cvs at cvs.gnupg.org
Tue Jan 3 22:59:17 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, master has been updated
       via  38fcd59ce774eaa3d65f2f7534c989afd860eb56 (commit)
      from  14cf1f7e338fedb8edaff5631441746605152bd6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 38fcd59ce774eaa3d65f2f7534c989afd860eb56
Author: Marcus Brinkmann <marcus.brinkmann at ruhr-uni-bochum.de>
Date:   Tue Jan 3 22:04:30 2012 +0100

    Fix pthread locking and remove defunctional support for static lock init.
    
    * src/ath.c: Include assert.h.
    (ath_mutex_destroy, ath_mutex_lock, ath_mutex_unlock): Dereference LOCK.
    * src/g10lib.h (_gcry_secmem_module_init): New declaration.
    * src/global.c (global_init): Call _gcry_secmem_module_init.
    * src/secmem.c (_gcry_secmem_module_init): New function.

diff --git a/src/ath.c b/src/ath.c
index 4834a52..1363d9e 100644
--- a/src/ath.c
+++ b/src/ath.c
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 
+#include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
@@ -46,11 +47,7 @@
 #endif
 
 /* For the dummy interface.  The MUTEX_NOTINIT value is used to check
-   that a mutex has been initialized.  Because its value is there is
-   no need to explicit initialized a mutex variable because it is
-   anyway static and we store a pointer to allocated memory there
-   after initialization.  The same thing works with other thread
-   models. */
+   that a mutex has been initialized.  */
 #define MUTEX_NOTINIT	((ath_mutex_t) 0)
 #define MUTEX_UNLOCKED	((ath_mutex_t) 1)
 #define MUTEX_LOCKED	((ath_mutex_t) 2)
@@ -231,7 +228,7 @@ ath_mutex_destroy (ath_mutex_t *lock)
 #if USE_POSIX_THREADS_WEAK
     case ath_model_pthreads_weak:
       {
-        pthread_mutex_t *plck = (pthread_mutex_t*)lock;
+        pthread_mutex_t *plck = (pthread_mutex_t*) (*lock);
 
         err = pthread_mutex_destroy (plck);
         if (!err)
@@ -263,7 +260,7 @@ ath_mutex_lock (ath_mutex_t *lock)
     {
     case ath_model_none:
       if (*lock == MUTEX_NOTINIT)
-        err = EINVAL;
+	err = EINVAL;
       else if (*lock == MUTEX_UNLOCKED)
         {
           *lock = MUTEX_LOCKED;
@@ -275,7 +272,7 @@ ath_mutex_lock (ath_mutex_t *lock)
 
 #if USE_POSIX_THREADS_WEAK
     case ath_model_pthreads_weak:
-      err = pthread_mutex_lock ((pthread_mutex_t*)lock);
+      err = pthread_mutex_lock ((pthread_mutex_t*)(*lock));
       break;
 #endif /*USE_POSIX_THREADS_WEAK*/
 
@@ -298,7 +295,7 @@ ath_mutex_unlock (ath_mutex_t *lock)
     {
     case ath_model_none:
       if (*lock == MUTEX_NOTINIT)
-        err = EINVAL;
+	err = EINVAL;
       else if (*lock == MUTEX_LOCKED)
         {
           *lock = MUTEX_UNLOCKED;
@@ -310,7 +307,7 @@ ath_mutex_unlock (ath_mutex_t *lock)
 
 #if USE_POSIX_THREADS_WEAK
     case ath_model_pthreads_weak:
-      err = pthread_mutex_unlock ((pthread_mutex_t*)lock);
+      err = pthread_mutex_unlock ((pthread_mutex_t*)(*lock));
       break;
 #endif /*USE_POSIX_THREADS_WEAK*/
 
diff --git a/src/g10lib.h b/src/g10lib.h
index f468ac4..93652ed 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -302,6 +302,7 @@ gcry_err_code_t _gcry_module_list (gcry_module_t modules,
 gcry_err_code_t _gcry_cipher_init (void);
 gcry_err_code_t _gcry_md_init (void);
 gcry_err_code_t _gcry_pk_init (void);
+gcry_err_code_t _gcry_secmem_module_init ();
 
 gcry_err_code_t _gcry_pk_module_lookup (int id, gcry_module_t *module);
 void _gcry_pk_module_release (gcry_module_t module);
diff --git a/src/global.c b/src/global.c
index 36d6646..bde8791 100644
--- a/src/global.c
+++ b/src/global.c
@@ -131,6 +131,9 @@ global_init (void)
   err = _gcry_primegen_init ();
   if (err)
     goto fail;
+  err = _gcry_secmem_module_init ();
+  if (err)
+    goto fail;
 
   return;
 
diff --git a/src/secmem.c b/src/secmem.c
index 2beb234..107c662 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -506,6 +506,19 @@ _gcry_secmem_init (size_t n)
 }
 
 
+gcry_err_code_t
+_gcry_secmem_module_init ()
+{
+  int err;
+
+  err = ath_mutex_init (&secmem_lock);
+  if (err)
+    log_fatal ("could not allocate secmem lock\n");
+
+  return 0;
+}
+
+
 static void *
 _gcry_secmem_malloc_internal (size_t size)
 {

-----------------------------------------------------------------------

Summary of changes:
 src/ath.c    |   17 +++++++----------
 src/g10lib.h |    1 +
 src/global.c |    3 +++
 src/secmem.c |   13 +++++++++++++
 4 files changed, 24 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org




More information about the Gnupg-commits mailing list