aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-05-06 09:36:06 +0000
committerWerner Koch <[email protected]>2009-05-06 09:36:06 +0000
commitb6798b5d8d337f4c750f7a6744fcb78687bf4f72 (patch)
tree30c47c7110324d3825f73c3c1daf9383795cb121
parent* gpgkeys_mailto.in: Set 'mail-from' as a keyserver-option, rather (diff)
downloadgnupg-b6798b5d8d337f4c750f7a6744fcb78687bf4f72.tar.gz
gnupg-b6798b5d8d337f4c750f7a6744fcb78687bf4f72.zip
Fix bug#1034.
Remove dead code.
Diffstat (limited to '')
-rw-r--r--g10/ChangeLog7
-rw-r--r--g10/getkey.c10
-rw-r--r--g10/keyring.c60
3 files changed, 42 insertions, 35 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 00fbfead2..9f4119889 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-06 Werner Koch <[email protected]>
+
+ * getkey.c (finish_lookup): Remove dead code.
+
+ * keyring.c (keyring_get_keyblock): Fix memory leak due to ring
+ trust packets. Fixes bug#1034.
+
2009-04-03 Werner Koch <[email protected]>
* gpgv.c (main): Open keyrings readonly.
diff --git a/g10/getkey.c b/g10/getkey.c
index d2f8ad962..54843cfb2 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -2640,16 +2640,6 @@ finish_lookup (GETKEY_CTX ctx)
goto found;
}
- if (!req_usage) {
- PKT_public_key *pk = foundk->pkt->pkt.public_key;
- if (pk->user_id)
- free_user_id (pk->user_id);
- pk->user_id = scopy_user_id (foundu);
- ctx->found_key = foundk;
- cache_user_id( keyblock );
- return 1; /* found */
- }
-
latest_date = 0;
latest_key = NULL;
/* do not look at subkeys if a certification key is requested */
diff --git a/g10/keyring.c b/g10/keyring.c
index c01834a6a..2c894312d 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -426,42 +426,52 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
}
in_cert = 1;
- if (pkt->pkttype == PKT_RING_TRUST) {
+ if (pkt->pkttype == PKT_RING_TRUST)
+ {
/*(this code is duplicated after the loop)*/
if ( lastnode
&& lastnode->pkt->pkttype == PKT_SIGNATURE
&& (pkt->pkt.ring_trust->sigcache & 1) ) {
- /* this is a ring trust packet with a checked signature
+ /* This is a ring trust packet with a checked signature
* status cache following directly a signature paket.
- * Set the cache status into that signature packet */
+ * Set the cache status into that signature packet. */
PKT_signature *sig = lastnode->pkt->pkt.signature;
sig->flags.checked = 1;
sig->flags.valid = !!(pkt->pkt.ring_trust->sigcache & 2);
}
- /* reset lastnode, so that we set the cache status only from
- * the ring trust packet immediately folling a signature */
+ /* Reset LASTNODE, so that we set the cache status only from
+ * the ring trust packet immediately following a signature. */
lastnode = NULL;
- }
- else {
- node = lastnode = new_kbnode (pkt);
- if (!keyblock)
- keyblock = node;
- else
- add_kbnode (keyblock, node);
-
- if ( pkt->pkttype == PKT_PUBLIC_KEY
- || pkt->pkttype == PKT_PUBLIC_SUBKEY
- || pkt->pkttype == PKT_SECRET_KEY
- || pkt->pkttype == PKT_SECRET_SUBKEY) {
- if (++pk_no == hd->found.pk_no)
- node->flag |= 1;
- }
- else if ( pkt->pkttype == PKT_USER_ID) {
- if (++uid_no == hd->found.uid_no)
- node->flag |= 2;
- }
- }
+ free_packet(pkt);
+ init_packet(pkt);
+ continue;
+ }
+
+
+ node = lastnode = new_kbnode (pkt);
+ if (!keyblock)
+ keyblock = node;
+ else
+ add_kbnode (keyblock, node);
+ switch (pkt->pkttype)
+ {
+ case PKT_PUBLIC_KEY:
+ case PKT_PUBLIC_SUBKEY:
+ case PKT_SECRET_KEY:
+ case PKT_SECRET_SUBKEY:
+ if (++pk_no == hd->found.pk_no)
+ node->flag |= 1;
+ break;
+
+ case PKT_USER_ID:
+ if (++uid_no == hd->found.uid_no)
+ node->flag |= 2;
+ break;
+
+ default:
+ break;
+ }
pkt = xmalloc (sizeof *pkt);
init_packet(pkt);