[git] GnuPG - branch, master, updated. gnupg-2.1.21-155-g24c7aa0

by Werner Koch cvs at cvs.gnupg.org
Tue Jul 25 15:36:56 CEST 2017


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 Privacy Guard".

The branch, master has been updated
       via  24c7aa0d58e3768690dd8ebef0e8e01af7e80f83 (commit)
      from  0ef50340ef68b2541d9a1aafa71f5400aef4dc7e (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 24c7aa0d58e3768690dd8ebef0e8e01af7e80f83
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Jul 25 15:22:48 2017 +0200

    common: Strip trailing slashes from the homedir.
    
    * common/homedir.c (default_homedir): Strip trailing slashes.
    (gnupg_set_homedir): Ditto.
    
    --
    
    is_gnupg_default_homedir() does not ignore trailing slashes when
    comparing directory names.  This can lead to multiple agents started
    on the same directory if the homedir was specified with --homedir or
    GNUPGHOME without or with a number of slashes.
    
    We now make sure that the home directory name never ends in a
    slash (except for the roo of course).
    
    GnuPG-bug-id: 3295
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/homedir.c b/common/homedir.c
index a30e8dc..149e1ec 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -247,7 +247,7 @@ default_homedir (void)
         {
           if (!dir || !*dir)
             {
-              char *tmp;
+              char *tmp, *p;
 
               tmp = read_w32_registry_string (NULL,
                                               GNUPG_REGISTRY_DIR,
@@ -258,7 +258,13 @@ default_homedir (void)
                   tmp = NULL;
                 }
               if (tmp)
-                saved_dir = tmp;
+                {
+                  /* Strip trailing backslashes.  */
+                  p = tmp + strlen (tmp) - 1;
+                  while (p > tmp && *p == '\\')
+                    *p-- = 0;
+                  saved_dir = tmp;
+                }
             }
 
           if (!saved_dir)
@@ -267,10 +273,27 @@ default_homedir (void)
       dir = saved_dir;
     }
 #endif /*HAVE_W32_SYSTEM*/
+
   if (!dir || !*dir)
     dir = GNUPG_DEFAULT_HOMEDIR;
-  else if (!is_gnupg_default_homedir (dir))
-    non_default_homedir = 1;
+  else
+    {
+      /* Strip trailing slashes if any.  */
+      if (dir[strlen (dir)-1] == '/')
+        {
+          char *tmp, *p;
+
+          tmp = xstrdup (dir);
+          p = tmp + strlen (tmp) - 1;
+          while (p > tmp && *p == '/')
+            *p-- = 0;
+
+          dir = tmp;
+        }
+
+      if (!is_gnupg_default_homedir (dir))
+        non_default_homedir = 1;
+    }
 
   return dir;
 }
@@ -403,12 +426,40 @@ w32_commondir (void)
 void
 gnupg_set_homedir (const char *newdir)
 {
+  char *tmp = NULL;
+
   if (!newdir || !*newdir)
     newdir = default_homedir ();
-  else if (!is_gnupg_default_homedir (newdir))
-    non_default_homedir = 1;
+  else
+    {
+      /* Remove trailing slashes from NEWSDIR.  */
+      if (newdir[strlen (newdir)-1] == '/'
+#ifdef HAVE_W32_SYSTEM
+          || newdir[strlen (newdir)-1] == '\\'
+#endif
+          )
+        {
+          char *p;
+
+          tmp = xstrdup (newdir);
+          p = tmp + strlen (tmp) - 1;
+          while (p > tmp
+                 && (*p == '/'
+#ifdef HAVE_W32_SYSTEM
+                     || *p == '\\'
+#endif
+                     )
+                 )
+            *p-- = 0;
+
+          newdir = tmp;
+        }
+      if (!is_gnupg_default_homedir (newdir))
+        non_default_homedir = 1;
+    }
   xfree (the_gnupg_homedir);
   the_gnupg_homedir = make_absfilename (newdir, NULL);;
+  xfree (tmp);
 }
 
 
diff --git a/configure.ac b/configure.ac
index 02ee1a2..764a62d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -486,7 +486,8 @@ AH_BOTTOM([
 #define SAFE_VERSION_DOT  '.'
 #define SAFE_VERSION_DASH '-'
 
-/* Some global constants. */
+/* Some global constants.
+ * Note that the homedir must not end in a slash.  */
 #ifdef HAVE_DOSISH_SYSTEM
 # ifdef HAVE_DRIVE_LETTERS
 #  define GNUPG_DEFAULT_HOMEDIR "c:/gnupg"

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

Summary of changes:
 common/homedir.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 configure.ac     |  3 ++-
 2 files changed, 59 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list