1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpg: Fix key conversion for SSH.

* g10/export.c (key_to_sshblob): Use put_membuf with length counted
beforehand, and use memcmp instead of strncmp.

--

GnuPG-bug-id: 5393
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2021-11-24 10:32:57 +09:00
parent c397ba3ac0
commit 07671917e4

View File

@ -2133,14 +2133,15 @@ key_to_sshblob (membuf_t *mb, const char *identifier, ...)
size_t buflen;
gcry_mpi_t a;
ulongtobuf (nbuf, (ulong)strlen (identifier));
buflen = strlen (identifier);
ulongtobuf (nbuf, (ulong)buflen);
put_membuf (mb, nbuf, 4);
put_membuf_str (mb, identifier);
if (!strncmp (identifier, "ecdsa-sha2-", 11))
put_membuf (mb, identifier, buflen);
if (buflen > 11 && !memcmp (identifier, "ecdsa-sha2-", 11))
{
ulongtobuf (nbuf, (ulong)strlen (identifier+11));
ulongtobuf (nbuf, (ulong)(buflen - 11));
put_membuf (mb, nbuf, 4);
put_membuf_str (mb, identifier+11);
put_membuf (mb, identifier+11, buflen - 11);
}
va_start (arg_ptr, identifier);
while ((a = va_arg (arg_ptr, gcry_mpi_t)))