[svn] GnuPG - r4860 - in trunk: g10 po sm
svn author wk
cvs at cvs.gnupg.org
Tue Oct 28 12:41:57 CET 2008
Author: wk
Date: 2008-10-28 12:41:52 +0100 (Tue, 28 Oct 2008)
New Revision: 4860
Modified:
trunk/g10/ChangeLog
trunk/g10/keyedit.c
trunk/po/be.po
trunk/po/ca.po
trunk/po/cs.po
trunk/po/da.po
trunk/po/de.po
trunk/po/el.po
trunk/po/eo.po
trunk/po/es.po
trunk/po/et.po
trunk/po/fi.po
trunk/po/fr.po
trunk/po/gl.po
trunk/po/hu.po
trunk/po/id.po
trunk/po/it.po
trunk/po/ja.po
trunk/po/nb.po
trunk/po/pl.po
trunk/po/pt.po
trunk/po/pt_BR.po
trunk/po/ro.po
trunk/po/ru.po
trunk/po/sk.po
trunk/po/sv.po
trunk/po/tr.po
trunk/po/zh_CN.po
trunk/po/zh_TW.po
trunk/sm/ChangeLog
trunk/sm/certdump.c
trunk/sm/gpgsm.h
Log:
fixed a bug in the prompt formatter.
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2008-10-23 19:58:20 UTC (rev 4859)
+++ trunk/g10/ChangeLog 2008-10-28 11:41:52 UTC (rev 4860)
@@ -1,3 +1,7 @@
+2008-10-24 Werner Koch <wk at g10code.com>
+
+ * keyedit.c (change_passphrase): Clear passphrase cache.
+
2008-10-20 Werner Koch <wk at g10code.com>
* gpgv.c: Mark all args of the stub fucntions as unused.
Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog 2008-10-23 19:58:20 UTC (rev 4859)
+++ trunk/sm/ChangeLog 2008-10-28 11:41:52 UTC (rev 4860)
@@ -1,3 +1,12 @@
+2008-10-28 Werner Koch <wk at 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 at g10code.com>
* import.c (popen_protect_tool): Add arg CTRL and assure that the
Modified: trunk/g10/keyedit.c
===================================================================
--- trunk/g10/keyedit.c 2008-10-23 19:58:20 UTC (rev 4859)
+++ trunk/g10/keyedit.c 2008-10-28 11:41:52 UTC (rev 4860)
@@ -1151,7 +1151,15 @@
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 @@
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;
}
}
Modified: trunk/po/be.po [not shown]
Modified: trunk/po/ca.po [not shown]
Modified: trunk/po/cs.po [not shown]
Modified: trunk/po/da.po [not shown]
Modified: trunk/po/de.po [not shown]
Modified: trunk/po/el.po [not shown]
Modified: trunk/po/eo.po [not shown]
Modified: trunk/po/es.po [not shown]
Modified: trunk/po/et.po [not shown]
Modified: trunk/po/fi.po [not shown]
Modified: trunk/po/fr.po [not shown]
Modified: trunk/po/gl.po [not shown]
Modified: trunk/po/hu.po [not shown]
Modified: trunk/po/id.po [not shown]
Modified: trunk/po/it.po [not shown]
Modified: trunk/po/ja.po [not shown]
Modified: trunk/po/nb.po [not shown]
Modified: trunk/po/pl.po [not shown]
Modified: trunk/po/pt.po [not shown]
Modified: trunk/po/pt_BR.po [not shown]
Modified: trunk/po/ro.po [not shown]
Modified: trunk/po/ru.po [not shown]
Modified: trunk/po/sk.po [not shown]
Modified: trunk/po/sv.po [not shown]
Modified: trunk/po/tr.po [not shown]
Modified: trunk/po/zh_CN.po [not shown]
Modified: trunk/po/zh_TW.po [not shown]
Modified: trunk/sm/certdump.c
===================================================================
--- trunk/sm/certdump.c 2008-10-23 19:58:20 UTC (rev 4859)
+++ trunk/sm/certdump.c 2008-10-28 11:41:52 UTC (rev 4860)
@@ -39,15 +39,7 @@
#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;
char *value;
@@ -719,9 +711,9 @@
}
-/* 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 @@
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 @@
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 @@
}
+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 @@
};
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
*p++ = *s;
}
*p = 0;
- free (name);
+ xfree (name);
return buffer;
}
Modified: trunk/sm/gpgsm.h
===================================================================
--- trunk/sm/gpgsm.h 2008-10-23 19:58:20 UTC (rev 4859)
+++ trunk/sm/gpgsm.h 2008-10-28 11:41:52 UTC (rev 4860)
@@ -267,6 +267,7 @@
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);
More information about the Gnupg-commits
mailing list