mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
gpg: Clean bogus subkey binding when cleaning a key.
* g10/trust.c (clean_key): Also clean bogus subkey bindings. -- GnuPG-bug-id: 2922 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
766c25018b
commit
356323768a
@ -1518,6 +1518,7 @@ do_export_one_keyblock (ctrl_t ctrl, kbnode_t keyblock, u32 *keyid,
|
|||||||
u32 subkidbuf[2], *subkid;
|
u32 subkidbuf[2], *subkid;
|
||||||
kbnode_t kbctx, node;
|
kbnode_t kbctx, node;
|
||||||
|
|
||||||
|
/* NB: walk_kbnode skips packets marked as deleted. */
|
||||||
for (kbctx=NULL; (node = walk_kbnode (keyblock, &kbctx, 0)); )
|
for (kbctx=NULL; (node = walk_kbnode (keyblock, &kbctx, 0)); )
|
||||||
{
|
{
|
||||||
if (skip_until_subkey)
|
if (skip_until_subkey)
|
||||||
|
34
g10/trust.c
34
g10/trust.c
@ -756,21 +756,41 @@ clean_one_uid (kbnode_t keyblock, kbnode_t uidnode, int noisy, int self_only,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* NB: This function marks the deleted nodes only and the caller is
|
||||||
|
* responsible to skip or remove them. */
|
||||||
void
|
void
|
||||||
clean_key (kbnode_t keyblock, int noisy, int self_only,
|
clean_key (kbnode_t keyblock, int noisy, int self_only,
|
||||||
int *uids_cleaned, int *sigs_cleaned)
|
int *uids_cleaned, int *sigs_cleaned)
|
||||||
{
|
{
|
||||||
kbnode_t uidnode;
|
kbnode_t node;
|
||||||
|
|
||||||
merge_keys_and_selfsig (keyblock);
|
merge_keys_and_selfsig (keyblock);
|
||||||
|
|
||||||
for (uidnode = keyblock->next;
|
for (node = keyblock->next;
|
||||||
uidnode && !(uidnode->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
node && !(node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
||||||
|| uidnode->pkt->pkttype == PKT_SECRET_SUBKEY);
|
|| node->pkt->pkttype == PKT_SECRET_SUBKEY);
|
||||||
uidnode = uidnode->next)
|
node = node->next)
|
||||||
{
|
{
|
||||||
if (uidnode->pkt->pkttype == PKT_USER_ID)
|
if (node->pkt->pkttype == PKT_USER_ID)
|
||||||
clean_one_uid (keyblock, uidnode,noisy, self_only,
|
clean_one_uid (keyblock, node, noisy, self_only,
|
||||||
uids_cleaned, sigs_cleaned);
|
uids_cleaned, sigs_cleaned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove bogus subkey binding signatures: The only signatures
|
||||||
|
* allowed are of class 0x18 and 0x28. */
|
||||||
|
log_assert (!node || (node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
||||||
|
|| node->pkt->pkttype == PKT_SECRET_SUBKEY));
|
||||||
|
for (; node; node = node->next)
|
||||||
|
{
|
||||||
|
if (is_deleted_kbnode (node))
|
||||||
|
continue;
|
||||||
|
if (node->pkt->pkttype == PKT_SIGNATURE
|
||||||
|
&& !(IS_SUBKEY_SIG (node->pkt->pkt.signature)
|
||||||
|
|| IS_SUBKEY_REV (node->pkt->pkt.signature)))
|
||||||
|
{
|
||||||
|
delete_kbnode (node);
|
||||||
|
if (sigs_cleaned)
|
||||||
|
++*sigs_cleaned;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user