[git] GnuPG - branch, master, updated. gnupg-2.1.11-122-g9354293
by Justus Winter
cvs at cvs.gnupg.org
Tue Apr 5 16:12:05 CEST 2016
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 GNU Privacy Guard".
The branch, master has been updated
via 9354293b8c9f234939bc04182f15e2fe512e914e (commit)
from f45ed07a0fffa3adbc75b9d5726108a066927599 (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 9354293b8c9f234939bc04182f15e2fe512e914e
Author: Justus Winter <justus at g10code.com>
Date: Tue Apr 5 16:01:05 2016 +0200
dirmngr: Autodetect PEM format in dirmngr-client.
* dirmngr/dirmngr-client.c (init_asctobin): New function.
(main): Move the initialization code to the new function.
(read_pem_certificate): Initialize base64 table.
(read_certificate): Try to decode certificates given in files as PEM
first.
GnuPG-bug-id: 1844
Signed-off-by: Justus Winter <justus at g10code.com>
diff --git a/dirmngr/dirmngr-client.c b/dirmngr/dirmngr-client.c
index 02920d6..c6a33d7 100644
--- a/dirmngr/dirmngr-client.c
+++ b/dirmngr/dirmngr-client.c
@@ -116,6 +116,25 @@ static unsigned char bintoasc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
static unsigned char asctobin[256]; /* runtime initialized */
+/* Build the helptable for radix64 to bin conversion. */
+static void
+init_asctobin (void)
+{
+ static int initialized;
+ int i;
+ unsigned char *s;
+
+ if (initialized)
+ return;
+ initialized = 1;
+
+ for (i=0; i < 256; i++ )
+ asctobin[i] = 255; /* Used to detect invalid characters. */
+ for (s=bintoasc, i=0; *s; s++, i++)
+ asctobin[*s] = i;
+}
+
+
/* Prototypes. */
static gpg_error_t read_certificate (const char *fname,
unsigned char **rbuf, size_t *rbuflen);
@@ -234,19 +253,6 @@ main (int argc, char **argv )
if (log_get_errorcount (0))
exit (2);
- /* Build the helptable for radix64 to bin conversion. */
- if (opt.pem)
- {
- int i;
- unsigned char *s;
-
- for (i=0; i < 256; i++ )
- asctobin[i] = 255; /* Used to detect invalid characters. */
- for (s=bintoasc, i=0; *s; s++, i++)
- asctobin[*s] = i;
- }
-
-
if (cmd_ping)
err = 0;
else if (cmd_lookup || cmd_loadcrl)
@@ -461,6 +467,8 @@ read_pem_certificate (const char *fname, unsigned char **rbuf, size_t *rbuflen)
s_waitend
} state = s_init;
+ init_asctobin ();
+
fp = fname? fopen (fname, "r") : stdin;
if (!fp)
return gpg_error_from_errno (errno);
@@ -612,6 +620,15 @@ read_certificate (const char *fname, unsigned char **rbuf, size_t *rbuflen)
if (opt.pem)
return read_pem_certificate (fname, rbuf, rbuflen);
+ else if (fname)
+ {
+ /* A filename has been given. Let's just assume it is in PEM
+ format and decode it, and fall back to interpreting it as
+ binary certificate if that fails. */
+ err = read_pem_certificate (fname, rbuf, rbuflen);
+ if (! err)
+ return 0;
+ }
fp = fname? fopen (fname, "rb") : stdin;
if (!fp)
-----------------------------------------------------------------------
Summary of changes:
dirmngr/dirmngr-client.c | 43 ++++++++++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 13 deletions(-)
hooks/post-receive
--
The GNU Privacy Guard
http://git.gnupg.org
More information about the Gnupg-commits
mailing list