summaryrefslogtreecommitdiffstats
path: root/g10/keyring.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2019-07-10 08:06:54 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2019-07-10 08:06:54 +0200
commita7a043e82555a9da984c6fb01bfec4990d904690 (patch)
tree0ee9971d392414da7f5352aebf24de04a28afddd /g10/keyring.c
parentgpg: Do not try the import fallback if the options are already used. (diff)
downloadgnupg2-a7a043e82555a9da984c6fb01bfec4990d904690.tar.xz
gnupg2-a7a043e82555a9da984c6fb01bfec4990d904690.zip
gpg: Fix keyring retrieval.
* g10/keyring.c (keyring_get_keyblock): Avoid O(N^2) append. GnuPG-bug-id: 4592 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'g10/keyring.c')
-rw-r--r--g10/keyring.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/g10/keyring.c b/g10/keyring.c
index 21791a6ac..5fa499759 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -473,11 +473,14 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
}
in_cert = 1;
- node = lastnode = new_kbnode (pkt);
+ node = new_kbnode (pkt);
if (!keyblock)
- keyblock = node;
+ keyblock = lastnode = node;
else
- add_kbnode (keyblock, node);
+ {
+ lastnode->next = node;
+ lastnode = node;
+ }
switch (pkt->pkttype)
{
case PKT_PUBLIC_KEY: