From: NIIBE Yutaka Date: Tue, 21 May 2019 06:50:28 +0000 (+0900) Subject: agent: For SSH key, don't put NUL-byte at the end. X-Git-Tag: archive/raspbian/2.2.12-1+rpi1+deb10u2^2~31 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b86db6eaada2d24d64aed7adabf85d95866a21e8;p=gnupg2.git 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 (cherry picked from commit 6e39541f4f488fe59eac399bad18c465f373a784) Gbp-Pq: Topic from-2.2.16 Gbp-Pq: Name agent-For-SSH-key-don-t-put-NUL-byte-at-the-end.patch --- diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 9255830..ce621f7 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -3033,8 +3033,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);