fixed a bug in the prompt formatter.
authorWerner Koch <wk@gnupg.org>
Tue, 28 Oct 2008 11:41:52 +0000 (11:41 +0000)
committerWerner Koch <wk@gnupg.org>
Tue, 28 Oct 2008 11:41:52 +0000 (11:41 +0000)
32 files changed:
g10/ChangeLog
g10/keyedit.c
po/be.po
po/ca.po
po/cs.po
po/da.po
po/de.po
po/el.po
po/eo.po
po/es.po
po/et.po
po/fi.po
po/fr.po
po/gl.po
po/hu.po
po/id.po
po/it.po
po/ja.po
po/nb.po
po/pl.po
po/pt.po
po/pt_BR.po
po/ro.po
po/ru.po
po/sk.po
po/sv.po
po/tr.po
po/zh_CN.po
po/zh_TW.po
sm/ChangeLog
sm/certdump.c
sm/gpgsm.h

index b9a9849..130ebd5 100644 (file)
@@ -1,3 +1,7 @@
+2008-10-24  Werner Koch  <wk@g10code.com>
+
+       * keyedit.c (change_passphrase): Clear passphrase cache.
+
 2008-10-20  Werner Koch  <wk@g10code.com>
 
        * gpgv.c: Mark all args of the stub fucntions as unused.
index cbb9d79..fd9f23b 100644 (file)
@@ -1151,7 +1151,15 @@ change_passphrase( KBNODE keyblock )
            no_primary_secrets = 1;
        }
        else {
+            u32 keyid[2];
+
            tty_printf(_("Key is protected.\n"));
+            
+            /* Clear the passphrase cache so that the user is required
+               to enter the old passphrase.  */
+            keyid_from_sk (sk, keyid);
+            passphrase_clear_cache (keyid, NULL, 0);
+
            rc = check_secret_key( sk, 0 );
            if( !rc )
                passphrase = get_last_passphrase();
@@ -1233,7 +1241,17 @@ change_passphrase( KBNODE keyblock )
                    log_error("protect_secret_key failed: %s\n",
                               g10_errstr(rc) );
                else
+                  {
+                    u32 keyid[2];
+                    
+                    /* Clear the cahce again so that the user is
+                       required to enter the new passphrase at the
+                       next operation.  */
+                    keyid_from_sk (sk, keyid);
+                    passphrase_clear_cache (keyid, NULL, 0);
+
                    changed++;
+                  }
                break;
            }
        }
index a664f82..8eabfa6 100644 (file)
--- a/po/be.po
+++ b/po/be.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.2.2\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2003-10-30 16:35+0200\n"
 "Last-Translator: Ales Nyakhaychyk <nab@mail.by>\n"
 "Language-Team: Belarusian <i18n@mova.org>\n"
index 86112ae..169b5c1 100644 (file)
--- a/po/ca.po
+++ b/po/ca.po
@@ -27,7 +27,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.4.0\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2005-02-04 02:04+0100\n"
 "Last-Translator: Jordi Mallach <jordi@gnu.org>\n"
 "Language-Team: Catalan <ca@dodds.net>\n"
index bf42d5c..11d969b 100644 (file)
--- a/po/cs.po
+++ b/po/cs.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg-1.3.92\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2004-11-26 09:12+0200\n"
 "Last-Translator: Roman Pavlik <rp@tns.cz>\n"
 "Language-Team: Czech <translations.cs@gnupg.cz>\n"
index 7f8bc5b..31b26be 100644 (file)
--- a/po/da.po
+++ b/po/da.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.0.0h\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2003-12-03 16:11+0100\n"
 "Last-Translator: Birger Langkjer <birger.langkjer@image.dk>\n"
 "Language-Team: Danish <dansk@klid.dk>\n"
index 7ec4952..eb696b6 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg-2.0.6\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2008-06-27 14:10+0200\n"
 "Last-Translator: Walter Koch <koch@u32.de>\n"
 "Language-Team: German <de@li.org>\n"
index 5f6b5a4..e47f790 100644 (file)
--- a/po/el.po
+++ b/po/el.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg-1.1.92\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2003-06-27 12:00+0200\n"
 "Last-Translator: Dokianakis Theofanis <madf@hellug.gr>\n"
 "Language-Team: Greek <nls@tux.hellug.gr>\n"
index 6c7944a..79b69a0 100644 (file)
--- a/po/eo.po
+++ b/po/eo.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.0.6d\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2002-04-14 14:33+0100\n"
 "Last-Translator: Edmund GRIMLEY EVANS <edmundo@rano.org>\n"
 "Language-Team: Esperanto <translation-team-eo@lists.sourceforge.net>\n"
index 56db256..99f8ec5 100644 (file)
--- a/po/es.po
+++ b/po/es.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 2.0.9\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2008-05-27 22:38+0100\n"
 "Last-Translator: Jaime Suárez <jaime@mundocripto.com>\n"
 "Language-Team: Spanish <es@li.org>\n"
index 091e5ca..57df36e 100644 (file)
--- a/po/et.po
+++ b/po/et.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.2.2\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2004-06-17 11:04+0300\n"
 "Last-Translator: Toomas Soome <Toomas.Soome@microlink.ee>\n"
 "Language-Team: Estonian <et@li.org>\n"
index 26c0fda..3f23e91 100644 (file)
--- a/po/fi.po
+++ b/po/fi.po
@@ -22,7 +22,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.2.2\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2004-06-16 22:40+0300\n"
 "Last-Translator: Tommi Vainikainen <Tommi.Vainikainen@iki.fi>\n"
 "Language-Team: Finnish <translation-team-fi@lists.sourceforge.net>\n"
index 296b81d..eba8332 100644 (file)
--- a/po/fr.po
+++ b/po/fr.po
@@ -11,7 +11,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.4.2rc2\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2008-09-30 19:38+0200\n"
 "Last-Translator: Gaël Quéri <gael@lautre.net>\n"
 "Language-Team: French <traduc@traduc.org>\n"
index cfe7b0a..465a7a6 100644 (file)
--- a/po/gl.po
+++ b/po/gl.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.2.4\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2003-12-04 11:39+0100\n"
 "Last-Translator: Jacobo Tarrio <jtarrio@trasno.net>\n"
 "Language-Team: Galician <gpul-traduccion@ceu.fi.udc.es>\n"
index 6644b6f..d0f0242 100644 (file)
--- a/po/hu.po
+++ b/po/hu.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.2.5\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2004-06-19 21:53+0200\n"
 "Last-Translator: Nagy Ferenc László <nfl@nfllab.com>\n"
 "Language-Team: Hungarian <translation-team-hu@lists.sourceforge.net>\n"
index 62d6ad9..8ed7e6d 100644 (file)
--- a/po/id.po
+++ b/po/id.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg-id\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2004-06-17 16:32+0700\n"
 "Last-Translator: Tedi Heriyanto <tedi_h@gmx.net>\n"
 "Language-Team: Indonesian <translation-team-id@lists.sourceforge.net>\n"
index 6c6c35c..cfe3287 100644 (file)
--- a/po/it.po
+++ b/po/it.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.1.92\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2008-05-26 12:02+0200\n"
 "Last-Translator: Marco d'Itri <md@linux.it>\n"
 "Language-Team: Italian <tp@lists.linux.it>\n"
index a7dd9e8..b514f97 100644 (file)
--- a/po/ja.po
+++ b/po/ja.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.3.92\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2004-11-23 11:14+0900\n"
 "Last-Translator: IIDA Yosiaki <iida@gnu.org>\n"
 "Language-Team: Japanese <translation-team-ja@lists.sourceforge.net>\n"
index 32241a3..ff1a0b0 100644 (file)
--- a/po/nb.po
+++ b/po/nb.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.4.3\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2006-06-13 20:31+0200\n"
 "Last-Translator: Trond Endrestøl <Trond.Endrestol@fagskolen.gjovik.no>\n"
 "Language-Team: Norwegian Bokmål <i18n-nb@lister.ping.uio.no>\n"
index 0f02e54..92af85e 100644 (file)
--- a/po/pl.po
+++ b/po/pl.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg-2.0.7\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2007-11-26 19:01+0100\n"
 "Last-Translator: Jakub Bogusz <qboosh@pld-linux.org>\n"
 "Language-Team: Polish <translation-team-pl@lists.sourceforge.net>\n"
index 803d75d..b00aa95 100644 (file)
--- a/po/pt.po
+++ b/po/pt.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2002-09-13 18:26+0100\n"
 "Last-Translator: Pedro Morais <morais@kde.org>\n"
 "Language-Team: pt <morais@kde.org>\n"
index 1419c15..bfa4b34 100644 (file)
@@ -13,7 +13,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.0\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2007-08-16 11:35+0200\n"
 "Last-Translator:\n"
 "Language-Team: ?\n"
index 66eddd7..3470927 100644 (file)
--- a/po/ro.po
+++ b/po/ro.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.4.2rc1\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2005-05-31 22:00-0500\n"
 "Last-Translator: Laurentiu Buzdugan <lbuz@rolix.org>\n"
 "Language-Team: Romanian <translation-team-ro@lists.sourceforge.net>\n"
index 9f553b0..a6a7831 100644 (file)
--- a/po/ru.po
+++ b/po/ru.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: GnuPG 2.0.0\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2006-11-07 19:31+0300\n"
 "Last-Translator: Maxim Britov <maxim.britov@gmail.com>\n"
 "Language-Team: Russian <gnupg-ru@gnupg.org>\n"
index d8ea76f..861409d 100644 (file)
--- a/po/sk.po
+++ b/po/sk.po
@@ -5,7 +5,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.2.5\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2004-07-20 15:52+0200\n"
 "Last-Translator: Michal Majer <mmajer@econ.umb.sk>\n"
 "Language-Team: Slovak <sk-i18n@lists.linux.sk>\n"
index ff09b83..f15cf1e 100644 (file)
--- a/po/sv.po
+++ b/po/sv.po
@@ -24,7 +24,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg trunk\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2008-07-21 09:04+0200\n"
 "Last-Translator: Daniel Nylander <po@danielnylander.se>\n"
 "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
index 5e8b105..b43faf4 100644 (file)
--- a/po/tr.po
+++ b/po/tr.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.9.94\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2006-11-04 03:45+0200\n"
 "Last-Translator: Nilgün Belma Bugüner <nilgun@belgeler.gen.tr>\n"
 "Language-Team: Turkish <gnu-tr-u12a@lists.sourceforge.net>\n"
index c749af2..bc28e39 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 1.4.4\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2006-07-02 10:58+0800\n"
 "Last-Translator: Meng Jie <zuxyhere@eastday.com>\n"
 "Language-Team: Chinese (simplified) <i18n-translation@lists.linux.net.cn>\n"
index cb66424..b53921a 100644 (file)
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gnupg 2.0.9\n"
 "Report-Msgid-Bugs-To: translations@gnupg.org\n"
-"POT-Creation-Date: 2008-10-23 21:02+0200\n"
+"POT-Creation-Date: 2008-10-23 21:20+0200\n"
 "PO-Revision-Date: 2008-03-26 22:35+0800\n"
 "Last-Translator: Jedi Lin <Jedi@Jedi.org>\n"
 "Language-Team: Chinese (traditional) <zh-l10n@linux.org.tw>\n"
index ce129cf..749bc58 100644 (file)
@@ -1,3 +1,12 @@
+2008-10-28  Werner Koch  <wk@g10code.com>
+
+       * certdump.c (gpgsm_format_keydesc): Use xtryasprintf and xfree.
+       (gpgsm_es_print_name): Factor code out to ...
+       (gpgsm_es_print_name2): New function.
+       (gpgsm_format_name2, format_name_writer): Use estream so that it
+       works on all platforms.
+       (format_name_writer): Fix reallocation bug.
+
 2008-10-23  Werner Koch  <wk@g10code.com>
 
        * import.c (popen_protect_tool): Add arg CTRL and assure that the
index 2dfbce1..6c360a3 100644 (file)
 #include "keydb.h"
 #include "i18n.h"
 
-#ifdef HAVE_FOPENCOOKIE
-typedef ssize_t my_funopen_hook_ret_t;
-typedef size_t  my_funopen_hook_size_t;
-#else
-typedef int     my_funopen_hook_ret_t;
-typedef int     my_funopen_hook_size_t;
-#endif
-
 
 struct dn_array_s {
   char *key;
@@ -719,9 +711,9 @@ gpgsm_print_name (FILE *fp, const char *name)
 }
 
 
-/* This is avariant of gpgsm_print_name sending it output to an estream. */
+/* This is a variant of gpgsm_print_name sending it output to an estream. */
 void
-gpgsm_es_print_name (estream_t fp, const char *name)
+gpgsm_es_print_name2 (estream_t fp, const char *name, int translate)
 {
   const unsigned char *s = (const unsigned char *)name;
   int i;
@@ -735,8 +727,13 @@ gpgsm_es_print_name (estream_t fp, const char *name)
       const char *s2 = strchr ( (char*)s+1, '>');
 
       if (s2)
-        es_write_sanitized_utf8_buffer (fp, s + 1, s2 - (char*)s - 1,
-                                        NULL, NULL);
+        {
+          if (translate)
+            es_write_sanitized_utf8_buffer (fp, s + 1, s2 - (char*)s - 1,
+                                            NULL, NULL);
+          else
+            es_write_sanitized (fp, s + 1, s2 - (char*)s - 1, NULL, NULL);
+        }
     }
   else if (*s == '(')
     {
@@ -754,7 +751,7 @@ gpgsm_es_print_name (estream_t fp, const char *name)
         es_fputs (_("[Error - invalid DN]"), fp);
       else 
         {
-          print_dn_parts (NULL, fp, dn, 1);          
+          print_dn_parts (NULL, fp, dn, translate);          
           for (i=0; dn[i].key; i++)
             {
               xfree (dn[i].key);
@@ -766,9 +763,13 @@ gpgsm_es_print_name (estream_t fp, const char *name)
 }
 
 
+void
+gpgsm_es_print_name (estream_t fp, const char *name)
+{
+  gpgsm_es_print_name2 (fp, name, 1);
+}
 
 
-#if defined (HAVE_FOPENCOOKIE) || defined (HAVE_FUNOPEN)
 /* A cookie structure used for the memory stream. */
 struct format_name_cookie 
 {
@@ -779,32 +780,55 @@ struct format_name_cookie
 };
 
 /* The writer function for the memory stream. */
-static my_funopen_hook_ret_t
-format_name_writer (void *cookie, const char *buffer,
-                    my_funopen_hook_size_t size)
+static ssize_t
+format_name_writer (void *cookie, const void *buffer, size_t size)
 {
   struct format_name_cookie *c = cookie;
   char *p;
 
-  if (c->buffer)
-    p = xtryrealloc (c->buffer, c->size + size + 1);
+  log_debug    ("buffer: size=%d len=%d error=%d: adding %d bytes\n", 
+                (int)c->size, (int)c->len, c->error, (int)size);
+  log_printhex ("Adding:", buffer, size);
+  if (!c->buffer)
+    {
+      p = xtrymalloc (size + 1 + 1);
+      if (p)
+        {
+          c->size = size + 1;
+          c->buffer = p;
+          c->len = 0;
+        }
+    }
+  else if (c->len + size < c->len)
+    {
+      p = NULL;
+      errno = ENOMEM;
+    }
+  else if (c->size < c->len + size)
+    {
+      p = xtryrealloc (c->buffer, c->len + size + 1);
+      if (p)
+        {
+          c->size = c->len + size;
+          c->buffer = p;
+        }
+    }
   else
-    p = xtrymalloc (size + 1);
+    p = c->buffer;
   if (!p)
     {
       c->error = errno;
       xfree (c->buffer);
+      c->buffer = NULL;
       errno = c->error;
-      return (my_funopen_hook_ret_t)(-1);
+      return -1;
     }
-  c->buffer = p;
   memcpy (p + c->len, buffer, size);
   c->len += size;
   p[c->len] = 0; /* Terminate string. */ 
 
-  return (my_funopen_hook_ret_t)size;
+  return (ssize_t)size;
 }
-#endif /*HAVE_FOPENCOOKIE || HAVE_FUNOPEN*/
 
 
 /* Format NAME which is expected to be in rfc2253 format into a better
@@ -815,24 +839,14 @@ format_name_writer (void *cookie, const char *buffer,
 char *
 gpgsm_format_name2 (const char *name, int translate)
 {
-#if defined (HAVE_FOPENCOOKIE) || defined (HAVE_FUNOPEN)
-  FILE *fp;
+  estream_t fp;
   struct format_name_cookie cookie;
+  es_cookie_io_functions_t io = { NULL };
 
   memset (&cookie, 0, sizeof cookie);
 
-#ifdef HAVE_FOPENCOOKIE
-  {
-    cookie_io_functions_t io = { NULL };
-    io.write = format_name_writer;
-    
-    fp = fopencookie (&cookie, "w", io);
-  }
-#else /*!HAVE_FOPENCOOKIE*/
-  {
-    fp = funopen (&cookie, NULL, format_name_writer, NULL, NULL);
-  }
-#endif /*!HAVE_FOPENCOOKIE*/
+  io.func_write = format_name_writer;
+  fp = es_fopencookie (&cookie, "w", io);
   if (!fp)
     {
       int save_errno = errno;
@@ -840,8 +854,8 @@ gpgsm_format_name2 (const char *name, int translate)
       errno = save_errno;
       return NULL;
     }
-  gpgsm_print_name2 (fp, name, translate);
-  fclose (fp);
+  gpgsm_es_print_name2 (fp, name, translate);
+  es_fclose (fp);
   if (cookie.error || !cookie.buffer)
     {
       xfree (cookie.buffer);
@@ -849,11 +863,9 @@ gpgsm_format_name2 (const char *name, int translate)
       return NULL;
     }
   return cookie.buffer;
-#else /* No fun - use the name verbatim. */
-  return xtrystrdup (name);
-#endif /* No fun. */
 }
 
+
 char *
 gpgsm_format_name (const char *name)
 {
@@ -920,7 +932,6 @@ gpgsm_fpr_and_name_for_status (ksba_cert_t cert)
 char *
 gpgsm_format_keydesc (ksba_cert_t cert)
 {
-  int rc;
   char *name, *subject, *buffer, *p;
   const char *s;
   ksba_isotime_t t;
@@ -931,8 +942,10 @@ gpgsm_format_keydesc (ksba_cert_t cert)
   char *orig_codeset;
 
   name = ksba_cert_get_subject (cert, 0);
+  log_printhex ("XXXX NAME: ", name, strlen (name));
   subject = name? gpgsm_format_name2 (name, 0) : NULL;
   ksba_free (name); name = NULL;
+  log_printhex ("YYYY NAME: ", subject, strlen (subject));
 
   sexp = ksba_cert_get_serial (cert);
   sn = sexp? gpgsm_format_serial (sexp) : NULL;
@@ -951,20 +964,19 @@ gpgsm_format_keydesc (ksba_cert_t cert)
 
   orig_codeset = i18n_switchto_utf8 ();
 
-  rc = asprintf (&name,
-                 _("Please enter the passphrase to unlock the"
-                   " secret key for the X.509 certificate:\n"
-                   "\"%s\"\n"
-                   "S/N %s, ID 0x%08lX,\n"
-                   "created %s, expires %s.\n" ),
-                 subject? subject:"?",
-                 sn? sn: "?",
-                 gpgsm_get_short_fingerprint (cert),
-                 created, expires);
-
+  name = xtryasprintf (_("Please enter the passphrase to unlock the"
+                         " secret key for the X.509 certificate:\n"
+                         "\"%s\"\n"
+                         "S/N %s, ID 0x%08lX,\n"
+                         "created %s, expires %s.\n" ),
+                       subject? subject:"?",
+                       sn? sn: "?",
+                       gpgsm_get_short_fingerprint (cert),
+                       created, expires);
+  
   i18n_switchback (orig_codeset);
-
-  if (rc < 0)
+  
+  if (!name)
     {
       int save_errno = errno;
       xfree (subject);
@@ -996,7 +1008,7 @@ gpgsm_format_keydesc (ksba_cert_t cert)
         *p++ = *s;
     }
   *p = 0;
-  free (name); 
+  xfree (name); 
 
   return buffer;
 }
index 0ee557f..1460dc0 100644 (file)
@@ -267,6 +267,7 @@ void gpgsm_print_time (estream_t fp, ksba_isotime_t t);
 void gpgsm_print_name2 (FILE *fp, const char *string, int translate);
 void gpgsm_print_name (FILE *fp, const char *string);
 void gpgsm_es_print_name (estream_t fp, const char *string);
+void gpgsm_es_print_name2 (estream_t fp, const char *string, int translate);
 
 void gpgsm_cert_log_name (const char *text, ksba_cert_t cert);