Allow no protection in pinentry-mode=loopback.
authorBen Kibbey <bjk@luxsci.net>
Tue, 13 Sep 2011 00:13:19 +0000 (20:13 -0400)
committerWerner Koch <wk@gnupg.org>
Tue, 13 Sep 2011 06:33:43 +0000 (08:33 +0200)
When the inquired passphrase has a 0 length then treat it as no
protection.

agent/ChangeLog
agent/genkey.c

index 18a9491..3c52e1f 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-12  Ben Kibbey <bjk@luxsci.net>
+
+       * genkey.c (agent_ask_new_passphrase): Allow for an empty passphrase
+       (no protection) in PINENTRY_MODE_LOOPBACK.
+
 2011-09-10  Ben Kibbey <bjk@luxsci.net>
 
        * agent.h (pinentry_loopback): New prototype.
index b022684..20b9230 100644 (file)
@@ -313,8 +313,13 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
        err = pinentry_loopback(ctrl, "NEW_PASSPHRASE", &buffer, &size, len);
        if (!err)
          {
-           buffer[size] = 0;
-           *r_passphrase = buffer;
+           if (size)
+             {
+               buffer[size] = 0;
+               *r_passphrase = buffer;
+             }
+           else
+               *r_passphrase = NULL;
          }
        return err;
     }