[Pkg-gnupg-commit] [gpgme] 293/412: core: Base gpgme_get_dirinfo(uiserver-socket) on the socket dir.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:27:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gpgme.

commit c9e7dcb100d807583d8e312da459561138231376
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Aug 22 16:32:14 2016 +0200

    core: Base gpgme_get_dirinfo(uiserver-socket) on the socket dir.
    
    * src/dirinfo.c (dirname_len): New.
    (parse_output): Change computation of UISRV_SOCKET.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 src/dirinfo.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/dirinfo.c b/src/dirinfo.c
index 8824c9a..226f93c 100644
--- a/src/dirinfo.c
+++ b/src/dirinfo.c
@@ -70,6 +70,15 @@ _gpgme_dirinfo_disable_gpgconf (void)
 }
 
 
+/* Return the length of the directory part including the trailing
+ * slash of NAME.  */
+static size_t
+dirname_len (const char *name)
+{
+  return _gpgme_get_basename (name) - name;
+}
+
+
 /* Parse the output of "gpgconf --list-dirs".  This function expects
    that DIRINFO_LOCK is held by the caller.  If COMPONENTS is set, the
    output of --list-components is expected. */
@@ -77,6 +86,7 @@ static void
 parse_output (char *line, int components)
 {
   char *value, *p;
+  size_t n;
 
   value = strchr (line, ':');
   if (!value)
@@ -110,22 +120,25 @@ parse_output (char *line, int components)
   else
     {
       if (!strcmp (line, "homedir") && !dirinfo.homedir)
+        dirinfo.homedir = strdup (value);
+      else if (!strcmp (line, "agent-socket") && !dirinfo.agent_socket)
         {
           const char name[] = "S.uiserver";
+          char *buffer;
 
-          dirinfo.homedir = strdup (value);
-          if (dirinfo.homedir)
+          dirinfo.agent_socket = strdup (value);
+          if (dirinfo.agent_socket)
             {
-              dirinfo.uisrv_socket = malloc (strlen (dirinfo
-                                                     .homedir)
-                                             + 1 + strlen (name) + 1);
-              if (dirinfo.uisrv_socket)
-                strcpy (stpcpy (stpcpy (dirinfo.uisrv_socket, dirinfo.homedir),
-                                DIRSEP_S), name);
+              n = dirname_len (dirinfo.agent_socket);
+              buffer = malloc (n + strlen (name) + 1);
+              if (buffer)
+                {
+                  strncpy (buffer, dirinfo.agent_socket, n);
+                  strcpy (buffer + n, name);
+                  dirinfo.uisrv_socket = buffer;
+                }
             }
         }
-      else if (!strcmp (line, "agent-socket") && !dirinfo.agent_socket)
-        dirinfo.agent_socket = strdup (value);
     }
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list