1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-28 21:50:02 +02:00

Fix bug#1034.

Remove dead code.
This commit is contained in:
Werner Koch 2009-05-06 09:36:06 +00:00
parent 4409dbf068
commit b6798b5d8d
3 changed files with 41 additions and 34 deletions

View File

@ -1,3 +1,10 @@
2009-05-06 Werner Koch <wk@g10code.com>
* 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 <wk@g10code.com> 2009-04-03 Werner Koch <wk@g10code.com>
* gpgv.c (main): Open keyrings readonly. * gpgv.c (main): Open keyrings readonly.

View File

@ -2640,16 +2640,6 @@ finish_lookup (GETKEY_CTX ctx)
goto found; 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_date = 0;
latest_key = NULL; latest_key = NULL;
/* do not look at subkeys if a certification key is requested */ /* do not look at subkeys if a certification key is requested */

View File

@ -426,42 +426,52 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
} }
in_cert = 1; in_cert = 1;
if (pkt->pkttype == PKT_RING_TRUST) { if (pkt->pkttype == PKT_RING_TRUST)
{
/*(this code is duplicated after the loop)*/ /*(this code is duplicated after the loop)*/
if ( lastnode if ( lastnode
&& lastnode->pkt->pkttype == PKT_SIGNATURE && lastnode->pkt->pkttype == PKT_SIGNATURE
&& (pkt->pkt.ring_trust->sigcache & 1) ) { && (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. * 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; PKT_signature *sig = lastnode->pkt->pkt.signature;
sig->flags.checked = 1; sig->flags.checked = 1;
sig->flags.valid = !!(pkt->pkt.ring_trust->sigcache & 2); sig->flags.valid = !!(pkt->pkt.ring_trust->sigcache & 2);
} }
/* reset lastnode, so that we set the cache status only from /* Reset LASTNODE, so that we set the cache status only from
* the ring trust packet immediately folling a signature */ * the ring trust packet immediately following a signature. */
lastnode = NULL; lastnode = NULL;
} free_packet(pkt);
else { init_packet(pkt);
node = lastnode = new_kbnode (pkt); continue;
if (!keyblock) }
keyblock = node;
else
add_kbnode (keyblock, node);
if ( pkt->pkttype == PKT_PUBLIC_KEY
|| pkt->pkttype == PKT_PUBLIC_SUBKEY node = lastnode = new_kbnode (pkt);
|| pkt->pkttype == PKT_SECRET_KEY if (!keyblock)
|| pkt->pkttype == PKT_SECRET_SUBKEY) { keyblock = node;
if (++pk_no == hd->found.pk_no) else
node->flag |= 1; add_kbnode (keyblock, node);
} switch (pkt->pkttype)
else if ( pkt->pkttype == PKT_USER_ID) { {
if (++uid_no == hd->found.uid_no) case PKT_PUBLIC_KEY:
node->flag |= 2; 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); pkt = xmalloc (sizeof *pkt);
init_packet(pkt); init_packet(pkt);