agent: Fix message for ACK button.
authorNIIBE Yutaka <gniibe@fsij.org>
Fri, 12 Oct 2018 02:36:59 +0000 (11:36 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Fri, 12 Oct 2018 02:36:59 +0000 (11:36 +0900)
* agent/divert-scd.c (getpin_cb): Display correct message.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
agent/divert-scd.c

index ad9b9ee..baa1cc3 100644 (file)
@@ -276,27 +276,49 @@ getpin_cb (void *opaque, const char *desc_text, const char *info,
         }
       else if (maxbuf == 1)  /* Open the pinentry. */
         {
-          if (info && strcmp (info, "--ack") != 0)
+          if (info)
             {
-              char *desc, *desc2;
+              char *desc;
+              const char *desc2;
 
-              if ( asprintf (&desc,
-                             L_("%s%%0A%%0AUse the reader's pinpad for input."),
-                             info) < 0 )
-                rc = gpg_error_from_syserror ();
+              if (!strcmp (info, "--ack"))
+                {
+                  desc2 = L_("Push ACK button on card/token.");
+
+                  if (desc_text)
+                    {
+                      desc = strconcat (desc_text,
+                                        has_percent0A_suffix (desc_text)
+                                        ? "%0A" : "%0A%0A",
+                                        desc2, NULL);
+                      desc2 = NULL;
+                    }
+                  else
+                    desc = NULL;
+                }
               else
                 {
-                  /* Prepend DESC_TEXT to INFO.  */
+                  desc2 = NULL;
+
                   if (desc_text)
-                    desc2 = strconcat (desc_text,
-                                       has_percent0A_suffix (desc_text)
-                                       ? "%0A" : "%0A%0A",
-                                       desc, NULL);
+                    desc = strconcat (desc_text,
+                                      has_percent0A_suffix (desc_text)
+                                      ? "%0A" : "%0A%0A",
+                                      info, "%0A%0A",
+                                      L_("Use the reader's pinpad for input."),
+                                      NULL);
                   else
-                    desc2 = NULL;
+                    desc = strconcat (info, "%0A%0A",
+                                      L_("Use the reader's pinpad for input."),
+                                      NULL);
+                }
+
+              if (!desc2 && !desc)
+                rc = gpg_error_from_syserror ();
+              else
+                {
                   rc = agent_popup_message_start (ctrl,
                                                   desc2? desc2:desc, NULL);
-                  xfree (desc2);
                   xfree (desc);
                 }
             }