[PATCH gnupg] agent: Avoid appending a '\0' byte to the response of READKEY

Katsuhiro Ueno uenobk at gmail.com
Wed Feb 7 10:52:37 CET 2018


* agent/command.c (cmd_readkey): Set pkbuflen to the length of the output
without an extra '\0' byte.
---
 agent/command.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/agent/command.c b/agent/command.c
index 7c7e8a4..36a21ae 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -1062,7 +1062,8 @@ cmd_readkey (assuan_context_t ctx, char *line)
             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);
             }
         }
-- 
2.16.1




More information about the Gnupg-devel mailing list