From 6e39541f4f488fe59eac399bad18c465f373a784 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 21 May 2019 15:50:28 +0900 Subject: [PATCH] agent: For SSH key, don't put NUL-byte at the end. * agent/command-ssh.c (ssh_key_to_protected_buffer): Update the length by the second call of gcry_sexp_sprint. -- GnuPG-bug-id: 4502 Signed-off-by: NIIBE Yutaka --- agent/command-ssh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 3cfd8aa14..d6729b70a 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -3003,8 +3003,8 @@ ssh_key_to_protected_buffer (gcry_sexp_t key, const char *passphrase, goto out; } - gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, buffer_new, buffer_new_n); - /* FIXME: guarantee? */ + buffer_new_n = gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, + buffer_new, buffer_new_n); if (*passphrase) err = agent_protect (buffer_new, passphrase, buffer, buffer_n, 0, -1);