[git] GPGME - branch, master, updated. gpgme-1.7.0-9-g583aafd

by Werner Koch cvs at cvs.gnupg.org
Thu Sep 22 13:02:36 CEST 2016


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  583aafdd6870a7fb12a34d90993fd0f46928592c (commit)
       via  c447b64d5989845a2ae2cf8fb30a92d2a0bd05af (commit)
       via  dc39552d01094eff2bef5f9fcd1c16928909d20e (commit)
      from  7a6543c2dfeef874a34086c8f3eeb1dbdf1ce822 (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 583aafdd6870a7fb12a34d90993fd0f46928592c
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Sep 22 12:58:23 2016 +0200

    w32: Silence some warnings about unused parameters.
    
    * src/assuan-support.c (my_recvmsg, my_sendmsg, my_waitpid)
    (my_socketpair) [W32]: Mark unused parameters.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/assuan-support.c b/src/assuan-support.c
index 2cfdc35..7fbd48a 100644
--- a/src/assuan-support.c
+++ b/src/assuan-support.c
@@ -97,6 +97,9 @@ my_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
 {
   (void)ctx;
 #ifdef HAVE_W32_SYSTEM
+  (void)fd;
+  (void)msg;
+  (void)flags;
   gpg_err_set_errno (ENOSYS);
   return -1;
 #else
@@ -112,6 +115,9 @@ my_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg,
 {
   (void)ctx;
 #ifdef HAVE_W32_SYSTEM
+  (void)fd;
+  (void)msg;
+  (void)flags;
   gpg_err_set_errno (ENOSYS);
   return -1;
 #else
@@ -210,6 +216,9 @@ my_waitpid (assuan_context_t ctx, pid_t pid,
 {
   (void)ctx;
 #ifdef HAVE_W32_SYSTEM
+  (void)nowait;
+  (void)status;
+  (void)options;
   CloseHandle ((HANDLE) pid);
 #else
   /* We can't just release the PID, a waitpid is mandatory.  But
@@ -229,6 +238,11 @@ my_socketpair (assuan_context_t ctx, int namespace, int style,
 	       int protocol, assuan_fd_t filedes[2])
 {
 #ifdef HAVE_W32_SYSTEM
+  (void)ctx;
+  (void)namespace;
+  (void)style;
+  (void)protocol;
+  (void)filedes;
   gpg_err_set_errno (ENOSYS);
   return -1;
 #else

commit c447b64d5989845a2ae2cf8fb30a92d2a0bd05af
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Sep 22 12:46:06 2016 +0200

    core: Fix error checking in _gpgme_mkstemp.
    
    * src/w32-util.c (_gpgme_mkstemp): Fix error checking.
    (dlopen): Mark FLAGS as unused.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/w32-util.c b/src/w32-util.c
index edac750..9d42139 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -98,6 +98,8 @@ static GPG_ERR_INLINE void *
 dlopen (const char * name, int flag)
 {
   void * hd = LoadLibrary (name);
+
+  (void)flag;
   return hd;
 }
 
@@ -754,7 +756,7 @@ _gpgme_mkstemp (int *fd, char **name)
   if (!tmpname)
     return -1;
   *fd = my_mkstemp (tmpname);
-  if (fd < 0)
+  if (*fd < 0)
     {
       free (tmpname);
       return -1;

commit dc39552d01094eff2bef5f9fcd1c16928909d20e
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Sep 22 12:41:55 2016 +0200

    core: New helper function _gpgme_strconcat.
    
    * src/conversion.c: Include stdarg.h.
    (do_strconcat): New.
    (_gpgme_strconcat): New.
    * src/util.h: Provide fallback for GPGRT_ATTR_SENTINEL.
    (_gpgme_strconcat): New with sentinel.
    
    * src/w32-util.c (find_program_in_dir): Replace malloc and stpcpy by
    _gpgme_strconcat.
    (find_program_at_standard_place): Ditto.
    (_gpgme_set_default_gpg_name): Ditto.
    (_gpgme_set_default_gpgconf_name): Ditto.
    (_gpgme_mkstemp): Ditto.
    (_gpgme_set_override_inst_dir): Repalce malloc and strcpy by strdup.
    --
    
    The function has been taken from gnupg/common/stringhelp.c and license
    changed to LPGLv2.1+.  I am the original author of that code.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/conversion.c b/src/conversion.c
index 3df8fe5..6dfabe7 100644
--- a/src/conversion.c
+++ b/src/conversion.c
@@ -31,6 +31,7 @@
 #endif
 #include <time.h>
 #include <errno.h>
+#include <stdarg.h>
 
 #include "gpgme.h"
 #include "util.h"
@@ -42,6 +43,61 @@
 
 
 

+static char *
+do_strconcat (const char *s1, va_list arg_ptr)
+{
+  const char *argv[16];
+  size_t argc;
+  size_t needed;
+  char *buffer, *p;
+
+  argc = 0;
+  argv[argc++] = s1;
+  needed = strlen (s1);
+  while (((argv[argc] = va_arg (arg_ptr, const char *))))
+    {
+      needed += strlen (argv[argc]);
+      if (argc >= DIM (argv)-1)
+        {
+          gpg_err_set_errno (EINVAL);
+          return NULL;
+        }
+      argc++;
+    }
+  needed++;
+  buffer = malloc (needed);
+  if (buffer)
+    {
+      for (p = buffer, argc=0; argv[argc]; argc++)
+        p = stpcpy (p, argv[argc]);
+    }
+  return buffer;
+}
+
+
+/* Concatenate the string S1 with all the following strings up to a
+ * NULL.  Returns a malloced buffer with the new string or NULL on a
+   malloc error or if too many arguments are given.  */
+char *
+_gpgme_strconcat (const char *s1, ...)
+{
+  va_list arg_ptr;
+  char *result;
+
+  if (!s1)
+    result = strdup ("");
+  else
+    {
+      va_start (arg_ptr, s1);
+      result = do_strconcat (s1, arg_ptr);
+      va_end (arg_ptr);
+    }
+  return result;
+}
+
+
+
+

 /* Convert two hexadecimal digits from STR to the value they
    represent.  Returns -1 if one of the characters is not a
    hexadecimal digit.  */
diff --git a/src/util.h b/src/util.h
index 88e7750..1474b41 100644
--- a/src/util.h
+++ b/src/util.h
@@ -49,6 +49,10 @@
 # define GPG_ERR_FALSE 256
 #endif
 
+#ifndef GPGRT_ATTR_SENTINEL
+# define GPGRT_ATTR_SENTINEL(a)  /* */
+#endif
+
 
 

 /*-- {posix,w32}-util.c --*/
@@ -102,6 +106,12 @@ int _gpgme_ttyname_r (int fd, char *buf, size_t buflen);
 
 

 /*-- conversion.c --*/
+
+/* Concatenate the string S1 with all the following strings up to a
+   NULL.  Returns a malloced buffer with the new string or NULL on a
+   malloc error or if too many arguments are given.  */
+char *_gpgme_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
+
 /* Convert two hexadecimal digits from STR to the value they
    represent.  Returns -1 if one of the characters is not a
    hexadecimal digit.  */
diff --git a/src/w32-util.c b/src/w32-util.c
index 0086fe3..edac750 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -388,11 +388,10 @@ find_program_in_dir (const char *dir, const char *name)
 {
   char *result;
 
-  result = malloc (strlen (dir) + 1 + strlen (name) + 1);
+  result = _gpgme_strconcat (dir, "\\", strlen (name), NULL);
   if (!result)
     return NULL;
 
-  strcpy (stpcpy (stpcpy (result, dir), "\\"), name);
   if (access (result, F_OK))
     {
       free (result);
@@ -417,15 +416,11 @@ find_program_at_standard_place (const char *name)
   if (SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILES, 0)
       || SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILESX86, 0))
     {
-      result = malloc (strlen (path) + 1 + strlen (name) + 1);
-      if (result)
+      result = _gpgme_strconcat (path, "\\", name, NULL);
+      if (result && access (result, F_OK))
         {
-          strcpy (stpcpy (stpcpy (result, path), "\\"), name);
-          if (access (result, F_OK))
-            {
-              free (result);
-              result = NULL;
-            }
+          free (result);
+          result = NULL;
         }
     }
   return result;
@@ -439,12 +434,9 @@ _gpgme_set_default_gpg_name (const char *name)
 {
   if (!default_gpg_name)
     {
-      default_gpg_name = malloc (strlen (name) + 5);
+      default_gpg_name = _gpgme_strconcat (name, ".exe", NULL);
       if (default_gpg_name)
-        {
-          strcpy (stpcpy (default_gpg_name, name), ".exe");
-          replace_slashes (default_gpg_name);
-        }
+        replace_slashes (default_gpg_name);
     }
   return !default_gpg_name;
 }
@@ -456,12 +448,9 @@ _gpgme_set_default_gpgconf_name (const char *name)
 {
   if (!default_gpgconf_name)
     {
-      default_gpgconf_name = malloc (strlen (name) + 5);
+      default_gpgconf_name = _gpgme_strconcat (name, ".exe", NULL);
       if (default_gpgconf_name)
-        {
-          strcpy (stpcpy (default_gpgconf_name, name), ".exe");
-          replace_slashes (default_gpgconf_name);
-        }
+        replace_slashes (default_gpgconf_name);
     }
   return !default_gpgconf_name;
 }
@@ -474,10 +463,9 @@ _gpgme_set_override_inst_dir (const char *dir)
 {
   if (!override_inst_dir)
     {
-      override_inst_dir = malloc (strlen (dir) + 1);
+      override_inst_dir = strdup (dir);
       if (override_inst_dir)
         {
-          strcpy (override_inst_dir, dir);
           replace_slashes (override_inst_dir);
           /* Remove a trailing slash.  */
           if (*override_inst_dir
@@ -762,10 +750,9 @@ _gpgme_mkstemp (int *fd, char **name)
 	}
     }
 
-  tmpname = malloc (strlen (tmp) + 13 + 1);
+  tmpname = _gpgme_strconcat (tmp, "\\gpgme-XXXXXX", NULL);
   if (!tmpname)
     return -1;
-  strcpy (stpcpy (tmpname, tmp), "\\gpgme-XXXXXX");
   *fd = my_mkstemp (tmpname);
   if (fd < 0)
     {

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

Summary of changes:
 src/assuan-support.c | 14 +++++++++++++
 src/conversion.c     | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/util.h           | 10 ++++++++++
 src/w32-util.c       | 39 +++++++++++++-----------------------
 4 files changed, 94 insertions(+), 25 deletions(-)


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




More information about the Gnupg-commits mailing list