From 4a4c1efac59f92b318b350265d1cc7b8365fcbdf Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 3 Sep 2024 14:06:48 +0900 Subject: [PATCH] agent: Fix KEYTOCARD for the use case with loopback pinentry. * agent/command.c (cmd_keytocard): Copy LINE. -- GnuPG-bug-id: 7283 Signed-off-by: NIIBE Yutaka --- agent/command.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agent/command.c b/agent/command.c index 3012680a1..580d1cb10 100644 --- a/agent/command.c +++ b/agent/command.c @@ -3291,6 +3291,12 @@ cmd_keytocard (assuan_context_t ctx, char *line) force = has_option (line, "--force"); line = skip_options (line); + /* Need a copy of LINE, since it might inquire to the frontend which + resulted original buffer overwritten. */ + line = xtrystrdup (line); + if (!line) + return gpg_error_from_syserror (); + argc = split_fields (line, argv, DIM (argv)); if (argc < 3) { @@ -3410,6 +3416,7 @@ cmd_keytocard (assuan_context_t ctx, char *line) xfree (keydata); leave: + xfree (line); xfree (ecdh_params); gcry_sexp_release (s_skey); xfree (shadow_info);