[git] Pinentry - branch, master, updated. pinentry-1.0.0-32-g1f5b351

by Daniel Kahn Gillmor cvs at cvs.gnupg.org
Thu Oct 12 23:14:50 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 standard pinentry collection".

The branch, master has been updated
       via  1f5b351531205214e9513a0aed170660dc822ceb (commit)
       via  242b658289488696d371c639c1da631712bd774c (commit)
      from  d7c54372512fbbd77709a3ea913b902061e5d45d (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 1f5b351531205214e9513a0aed170660dc822ceb
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Sun Feb 5 00:20:47 2017 -0500

    core: Only scan for the command line if probably on the same host.
    
    * pinentry/pinentry.c (pinentry_get_title): Check the current hostname
    and make sure it matches.  If it does not, do not bother looking for
    the command line.
    
    --
    
    If we don't do this, and the agent is forwarded from somewhere else,
    pinentry will be looking up arbitrary process command lines.
    
    Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>

diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 3303c77..2ba4baa 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <assert.h>
+#include <sys/utsname.h>
 #ifndef HAVE_W32CE_SYSTEM
 # include <locale.h>
 #endif
@@ -441,19 +442,22 @@ pinentry_get_title (pinentry_t pe)
   else if (pe->owner_pid)
     {
       char buf[200];
-      char *cmdline = get_cmdline (pe->owner_pid);
+      struct utsname utsbuf;
+      char *cmdline = NULL;
+
+      if (pe->owner_host &&
+          !uname (&utsbuf) && utsbuf.nodename &&
+          !strcmp (utsbuf.nodename, pe->owner_host))
+        cmdline = get_cmdline (pe->owner_pid);
 
       if (pe->owner_host && cmdline)
         snprintf (buf, sizeof buf, "[%lu]@%s (%s)",
                   pe->owner_pid, pe->owner_host, cmdline);
-      else if (cmdline)
-        snprintf (buf, sizeof buf, "[%lu] (%s)",
-                  pe->owner_pid, cmdline);
       else if (pe->owner_host)
         snprintf (buf, sizeof buf, "[%lu]@%s",
                   pe->owner_pid, pe->owner_host);
       else
-        snprintf (buf, sizeof buf, "[%lu]",
+        snprintf (buf, sizeof buf, "[%lu] <unknown host>",
                   pe->owner_pid);
       buf[sizeof buf - 1] = 0;
       free (cmdline);

commit 242b658289488696d371c639c1da631712bd774c
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Sat Feb 4 23:11:51 2017 -0500

    core: Clean up command line extraction.
    
    * pinentry/pinentry.c (get_cmdline): Avoid trailing space, and return
    NULL when no bytes were read from /proc.
    
    Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>

diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 5f7912a..3303c77 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -413,14 +413,16 @@ get_cmdline (unsigned long pid)
       fclose (fp);
       return NULL;
     }
-  /* Arguments are delimites by Nuls.  We should do proper quoting but
+  fclose (fp);
+  if (n == 0)
+    return NULL;
+  /* Arguments are delimited by Nuls.  We should do proper quoting but
    * that can be a bit complicated, thus we simply replace the Nuls by
    * spaces.  */
   for (i=0; i < n; i++)
-    if (!buffer[i])
+    if (!buffer[i] && i < n-1)
       buffer[i] = ' ';
   buffer[i] = 0; /* Make sure the last byte is the string terminator.  */
-  fclose (fp);
 
   return strdup (buffer);
 }

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

Summary of changes:
 pinentry/pinentry.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
The standard pinentry collection
http://git.gnupg.org




More information about the Gnupg-commits mailing list