agent: Avoid appending a '\0' byte to the response of READKEY
authorKatsuhiro Ueno <uenobk@gmail.com>
Wed, 7 Feb 2018 09:52:37 +0000 (18:52 +0900)
committerWerner Koch <wk@gnupg.org>
Wed, 14 Feb 2018 16:11:17 +0000 (17:11 +0100)
* agent/command.c (cmd_readkey): Set pkbuflen to the length of the output
without an extra '\0' byte.

agent/command.c

index 3a547ff..f9bc6ca 100644 (file)
@@ -1031,7 +1031,8 @@ cmd_readkey (assuan_context_t ctx, char *line)
             rc = gpg_error_from_syserror ();
           else
             {
             rc = gpg_error_from_syserror ();
           else
             {
-              gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, pkbuf, pkbuflen);
+              pkbuflen = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON,
+                                           pkbuf, pkbuflen);
               rc = assuan_send_data (ctx, pkbuf, pkbuflen);
             }
         }
               rc = assuan_send_data (ctx, pkbuf, pkbuflen);
             }
         }