agent, g10: Fix keygen.
authorNIIBE Yutaka <gniibe@fsij.org>
Thu, 20 Oct 2016 11:01:46 +0000 (20:01 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Thu, 20 Oct 2016 11:01:46 +0000 (20:01 +0900)
* agent/command.c (cmd_readkey): Get length after card_readkey.
* g10/keygen.c (gen_card_key): Fix off-by-one error.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
agent/command.c
g10/keygen.c

index a291d5b..7d8b4c4 100644 (file)
@@ -1020,10 +1020,10 @@ cmd_readkey (assuan_context_t ctx, char *line)
           goto leave;
         }
 
-      pkbuflen = gcry_sexp_canon_len (pkbuf, 0, NULL, NULL);
       rc = agent_card_readkey (ctrl, keyid, &pkbuf);
       if (rc)
         goto leave;
+      pkbuflen = gcry_sexp_canon_len (pkbuf, 0, NULL, NULL);
       rc = gcry_sexp_sscan (&s_pkey, NULL, (char*)pkbuf, pkbuflen);
       if (rc)
         goto leave;
index 90f8544..2115b5a 100644 (file)
@@ -4876,7 +4876,7 @@ gen_card_key (int algo, int keyno, int is_primary, kbnode_t pub_root,
   unsigned char *public;
   gcry_sexp_t s_key;
 
-  snprintf (keyid, DIM(keyid)-1, "OPENPGP.%d", keyno);
+  snprintf (keyid, DIM(keyid), "OPENPGP.%d", keyno);
   keyid[DIM(keyid)-1] = 0;
 
   if (algo != PUBKEY_ALGO_RSA)