[git] Pinentry - branch, master, updated. pinentry-0.9.2-28-gd3c52a1

by Neal H. Walfield cvs at cvs.gnupg.org
Sat May 16 22:34:02 CEST 2015


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  d3c52a144b5b23d0d841a99a310090dcafe2074b (commit)
       via  1d3583a2562e83496ac515276e9bd63a7f1abbc7 (commit)
       via  97a47ee99e14e0c8c6a2c3c5eec0434e6eac77e0 (commit)
       via  c33073eb40ee4bb6e079605dbf2f343de50390d7 (commit)
       via  c7736745f5683b820ebbd11e30ddb425748c16ab (commit)
      from  88772ddaac96303a63c97a45c26144d93a942798 (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 d3c52a144b5b23d0d841a99a310090dcafe2074b
Author: Neal H. Walfield <neal at gnu.org>
Date:   Sat May 16 22:33:05 2015 +0200

    curses: Handle control-u, control-w and alt-backspace.
    
    * pinentry/pinentry-curses.c (dialog_input): Take additional argument,
    alt.  Update callers.  If passed control-u, erase the whole line.  If
    passed alt-backspace or control-w, erase any white space the the
    previous word.
    (dialog_run): Detect when alt is pressed.

diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index e722009..183fdb4 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -678,12 +678,16 @@ dialog_switch_pos (dialog_t diag, dialog_pos_t new_pos)
 
 /* XXX Assume that field width is at least > 5.  */
 static void
-dialog_input (dialog_t diag, int chr)
+dialog_input (dialog_t diag, int alt, int chr)
 {
   int old_loc = diag->pin_loc;
   assert (diag->pinentry->pin);
   assert (diag->pos == DIALOG_POS_PIN);
 
+  if (alt && chr == KEY_BACKSPACE)
+    /* Remap alt-backspace to control-W.  */
+    chr = 'w' - 'a' + 1;
+
   switch (chr)
     {
     case KEY_BACKSPACE:
@@ -700,6 +704,43 @@ dialog_input (dialog_t diag, int chr)
 	}
       break;
 
+    case 'u' - 'a' + 1: /* control-u */
+      /* Erase the whole line.  */
+      if (diag->pin_len > 0)
+	{
+	  diag->pin_len = 0;
+	  diag->pin_loc = 0;
+	}
+      break;
+
+    case 'w' - 'a' + 1: /* control-w.  */
+      while (diag->pin_len > 0
+	     && diag->pinentry->pin[diag->pin_len - 1] == ' ')
+	{
+	  diag->pin_len --;
+	  diag->pin_loc --;
+	  if (diag->pin_loc < 0)
+	    {
+	      diag->pin_loc += diag->pin_size;
+	      if (diag->pin_loc > diag->pin_len)
+		diag->pin_loc = diag->pin_len;
+	    }
+	}
+      while (diag->pin_len > 0
+	     && diag->pinentry->pin[diag->pin_len - 1] != ' ')
+	{
+	  diag->pin_len --;
+	  diag->pin_loc --;
+	  if (diag->pin_loc < 0)
+	    {
+	      diag->pin_loc += diag->pin_size;
+	      if (diag->pin_loc > diag->pin_len)
+		diag->pin_loc = diag->pin_len;
+	    }
+	}
+
+      break;
+
     default:
       if (chr > 0 && chr < 256 && diag->pin_len < diag->pin_max)
 	{
@@ -752,6 +793,7 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
 #endif
 #ifdef HAVE_NCURSESW
   char *old_ctype = NULL;
+  int alt = 0;
 
   if (pinentry->lc_ctype)
     {
@@ -881,6 +923,11 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
           break;
 #endif
 
+	case 27: /* Alt was pressed.  */
+	  alt = 1;
+	  /* Get the next key press.  */
+	  continue;
+
 	case KEY_LEFT:
 	case KEY_UP:
 	  switch (diag.pos)
@@ -974,11 +1021,13 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
 
 	default:
 	  if (diag.pos == DIALOG_POS_PIN)
-	    dialog_input (&diag, c);
+	    dialog_input (&diag, alt, c);
 	}
 #ifndef HAVE_DOSISH_SYSTEM
       no_input = 0;
 #endif
+      if (c != -1)
+	alt = 0;
     }
   while (!done);
 

commit 1d3583a2562e83496ac515276e9bd63a7f1abbc7
Author: Neal H. Walfield <neal at gnu.org>
Date:   Sat May 16 21:35:02 2015 +0200

    secmem: Clear the buffer before returning it from secmem_malloc.
    
    * secmem/secmem.c (secmem_malloc): In case wipememory2 gets optimized
    away in secmem_free, clear the buffer before returning it.

diff --git a/secmem/secmem.c b/secmem/secmem.c
index c5da0b5..9a478cf 100644
--- a/secmem/secmem.c
+++ b/secmem/secmem.c
@@ -363,6 +363,8 @@ secmem_malloc( size_t size )
     if( cur_blocks > max_blocks )
 	max_blocks = cur_blocks;
 
+    memset (&mb->u.aligned.c, 0, size);
+
     return &mb->u.aligned.c;
 }
 

commit 97a47ee99e14e0c8c6a2c3c5eec0434e6eac77e0
Author: Neal H. Walfield <neal at gnu.org>
Date:   Sat May 16 21:34:06 2015 +0200

    curses: NUL terminate the pin entry buffer.
    
    * pinentry/pinentry-curses.c (dialog_run): NUL terminate the pin entry
    buffer.

diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 52abc1f..e722009 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -982,6 +982,11 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
     }
   while (!done);
 
+  if (diag.pinentry->pin)
+    /* NUL terminate the passphrase.  dialog_run makes sure there is
+       enough space for the terminating NUL byte.  */
+    diag.pinentry->pin[diag.pin_len] = 0;
+
   set_cursor_state (1);
   endwin ();
   if (screen)

commit c33073eb40ee4bb6e079605dbf2f343de50390d7
Author: Neal H. Walfield <neal at gnu.org>
Date:   Sat May 16 21:30:33 2015 +0200

    curses: Make sure the pin entry buffer is larger enough.
    
    * pinentry/pinentry-curses.c (dialog_input): Make sure the pin entry
    buffer is large enough.

diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 0b9689d..52abc1f 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -703,6 +703,13 @@ dialog_input (dialog_t diag, int chr)
     default:
       if (chr > 0 && chr < 256 && diag->pin_len < diag->pin_max)
 	{
+	  /* Make sure there is enough room for this character and a
+	     following NUL byte.  */
+	  if (! pinentry_setbufferlen (diag->pinentry, diag->pin_len + 2))
+	    {
+	      /* XXX: Bail.  */
+	    }
+
 	  diag->pinentry->pin[diag->pin_len] = (char) chr;
 	  diag->pin_len++;
 	  diag->pin_loc++;

commit c7736745f5683b820ebbd11e30ddb425748c16ab
Author: Neal H. Walfield <neal at gnu.org>
Date:   Sat May 16 21:25:42 2015 +0200

    curses: Avoid aliasing the pin buffer.
    
    * pinentry/pinentry-curses.c (struct dialog): Remove field pin.  Add
    field pinentry.
    (dialog_create): Don't set DIALOG->PIN to PINENTRY->PIN.  Set
    DIALOG->PINENTRY to PINENTRY and access PIN via
    DIALOG->PINENTRY->PIN.  Update other users.

diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 22e1e23..0b9689d 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -88,7 +88,6 @@ struct dialog
   int pin_size;
   /* Cursor location in PIN field.  */
   int pin_loc;
-  char *pin;
   int pin_max;
   /* Length of PIN.  */
   int pin_len;
@@ -102,6 +101,8 @@ struct dialog
   int notok_y;
   int notok_x;
   char *notok;
+
+  pinentry_t pinentry;
 };
 typedef struct dialog *dialog_t;
 
@@ -239,6 +240,8 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
   CH *error = NULL;
   CH *prompt = NULL;
 
+  dialog->pinentry = pinentry;
+
 #define COPY_OUT(what)							\
   do									\
     if (pinentry->what)							\
@@ -417,7 +420,6 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
     }
 
   dialog->pos = DIALOG_POS_NONE;
-  dialog->pin = pinentry->pin;
   dialog->pin_max = pinentry->pin_len;
   dialog->pin_loc = 0;
   dialog->pin_len = 0;
@@ -679,7 +681,7 @@ static void
 dialog_input (dialog_t diag, int chr)
 {
   int old_loc = diag->pin_loc;
-  assert (diag->pin);
+  assert (diag->pinentry->pin);
   assert (diag->pos == DIALOG_POS_PIN);
 
   switch (chr)
@@ -701,7 +703,7 @@ dialog_input (dialog_t diag, int chr)
     default:
       if (chr > 0 && chr < 256 && diag->pin_len < diag->pin_max)
 	{
-	  diag->pin[diag->pin_len] = (char) chr;
+	  diag->pinentry->pin[diag->pin_len] = (char) chr;
 	  diag->pin_len++;
 	  diag->pin_loc++;
 	  if (diag->pin_loc == diag->pin_size && diag->pin_len < diag->pin_max)
@@ -842,7 +844,8 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
         fclose (ttyfo);
       return -2;
     }
-  dialog_switch_pos (&diag, diag.pin ? DIALOG_POS_PIN : DIALOG_POS_OK);
+  dialog_switch_pos (&diag,
+		     diag.pinentry->pin ? DIALOG_POS_PIN : DIALOG_POS_OK);
 
 #ifndef HAVE_DOSISH_SYSTEM
   wtimeout (stdscr, 70);
@@ -876,7 +879,7 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
 	  switch (diag.pos)
 	    {
 	    case DIALOG_POS_OK:
-	      if (diag.pin)
+	      if (diag.pinentry->pin)
 		dialog_switch_pos (&diag, DIALOG_POS_PIN);
 	      break;
 	    case DIALOG_POS_NOTOK:
@@ -930,7 +933,7 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
 	      dialog_switch_pos (&diag, DIALOG_POS_CANCEL);
 	      break;
 	    case DIALOG_POS_CANCEL:
-	      if (diag.pin)
+	      if (diag.pinentry->pin)
 		dialog_switch_pos (&diag, DIALOG_POS_PIN);
 	      else
 		dialog_switch_pos (&diag, DIALOG_POS_OK);
@@ -1012,7 +1015,10 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
   if (done == -2)
     pinentry->canceled = 1;
 
-  return diag.pin ? (done < 0 ? -1 : diag.pin_len) : (done < 0 ? 0 : 1);
+  if (diag.pinentry->pin)
+    return done < 0 ? -1 : diag.pin_len;
+  else
+    return done < 0 ? 0 : 1;
 }
 
 

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

Summary of changes:
 pinentry/pinentry-curses.c | 87 ++++++++++++++++++++++++++++++++++++++++------
 secmem/secmem.c            |  2 ++
 2 files changed, 79 insertions(+), 10 deletions(-)


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




More information about the Gnupg-commits mailing list