[git] GPGME - branch, master, updated. gpgme-1.10.0-41-g59fe3f2

by NIIBE Yutaka cvs at cvs.gnupg.org
Tue Feb 27 10:51:29 CET 2018


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 "GnuPG Made Easy".

The branch, master has been updated
       via  59fe3f26c1ca0fba16f76738cd05aaf80fb735ef (commit)
      from  c58f61e92226c4a03f216f5d07bdc5479ce8a2d9 (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 59fe3f26c1ca0fba16f76738cd05aaf80fb735ef
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Tue Feb 27 18:43:40 2018 +0900

    core: Support non-thread-safe getenv.
    
    * src/get-env.c (_gpgme_getenv): Use gpgrt_lock_lock
    and gpgrt_lock_unlock to protect call of getnev.
    
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/src/get-env.c b/src/get-env.c
index 1adbeee..b13706f 100644
--- a/src/get-env.c
+++ b/src/get-env.c
@@ -28,29 +28,11 @@
 #include "util.h"
 
 

-#if defined(HAVE_THREAD_SAFE_GETENV)
-/* We prefer using getenv() if it is thread-safe.  */
-
 /* Retrieve the environment variable NAME and return a copy of it in a
    malloc()'ed buffer in *VALUE.  If the environment variable is not
    set, return NULL in *VALUE.  */
-gpgme_error_t
-_gpgme_getenv (const char *name, char **value)
-{
-  char *env_value;
 
-  env_value = getenv (name);
-  if (!env_value)
-    *value = NULL;
-  else
-    {
-      *value = strdup (env_value);
-      if (!*value)
-	return gpg_error_from_syserror ();
-    }
-  return 0;
-}
-#elif defined (HAVE_GETENV_R)
+#ifdef HAVE_GETENV_R
 #define INITIAL_GETENV_SIZE 32
 
 gpgme_error_t
@@ -91,7 +73,41 @@ _gpgme_getenv (const char *name, char **value)
   return 0;
 }
 #else
+#ifndef HAVE_THREAD_SAFE_GETENV
+GPGRT_LOCK_DEFINE (environ_lock);
+#endif
+
+gpgme_error_t
+_gpgme_getenv (const char *name, char **value)
+{
+  char *env_value;
+  gpgme_error_t err = 0;
 
-#error No thread-safe getenv nor getenv_r
+#ifndef HAVE_THREAD_SAFE_GETENV
+  gpg_err_code_t rc;
 
+  rc= gpgrt_lock_lock (&environ_lock);
+  if (rc)
+    {
+      err = gpg_error (rc);
+      goto leave;
+    }
+#endif
+  env_value = getenv (name);
+  if (!env_value)
+    *value = NULL;
+  else
+    {
+      *value = strdup (env_value);
+      if (!*value)
+	err = gpg_error_from_syserror ();
+    }
+#ifndef HAVE_THREAD_SAFE_GETENV
+  rc = gpgrt_lock_unlock (&environ_lock);
+  if (rc)
+    err = gpg_error (rc);
+ leave:
+#endif
+  return err;
+}
 #endif

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

Summary of changes:
 src/get-env.c | 56 ++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 36 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list