diff options
| author | Werner Koch <[email protected]> | 2025-02-11 13:44:23 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2025-02-11 13:46:19 +0000 |
| commit | 70049e5f16b412bcaaf97e6ea05613593c0c4247 (patch) | |
| tree | dee5a422dc05e630c8042a9d7cc4bd4bdb1c0ff3 /g10/import.c | |
| parent | Update NEWS (diff) | |
| download | gnupg-70049e5f16b412bcaaf97e6ea05613593c0c4247.tar.gz gnupg-70049e5f16b412bcaaf97e6ea05613593c0c4247.zip | |
gpg: Lookup key for merging/inserting only beu primary key.
* g10/getkey.c (get_keyblock_byfpr_fast): Add arg primary_only and
implement.
* g10/import.c (import_one_real): Simplify filling the fpr buffer with
zeroes.
(import_one_real): Find key only by primary fingerprint.
--
This should have been done early: When looking up the original
keyblock we want to update, we need to lookup it up only using the
primary key. This avoids to find a key which has the primary key also
has a subkey.
GnuPG-bug-id: 7527
Diffstat (limited to 'g10/import.c')
| -rw-r--r-- | g10/import.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/g10/import.c b/g10/import.c index ee41bcf24..09a2c2432 100644 --- a/g10/import.c +++ b/g10/import.c @@ -1994,7 +1994,6 @@ import_one_real (ctrl_t ctrl, int mod_key = 0; int same_key = 0; int non_self_or_utk = 0; - size_t an; char pkstrbuf[PUBKEY_STRING_SIZE]; int merge_keys_done = 0; int any_filter = 0; @@ -2015,8 +2014,8 @@ import_one_real (ctrl_t ctrl, pk = node->pkt->pkt.public_key; fingerprint_from_pk (pk, fpr2, &fpr2len); - for (an = fpr2len; an < MAX_FINGERPRINT_LEN; an++) - fpr2[an] = 0; + if (MAX_FINGERPRINT_LEN > fpr2len) + memset (fpr2+fpr2len, 0, MAX_FINGERPRINT_LEN - fpr2len); keyid_from_pk( pk, keyid ); uidnode = find_next_kbnode( keyblock, PKT_USER_ID ); @@ -2215,6 +2214,7 @@ import_one_real (ctrl_t ctrl, /* Do we have this key already in one of our pubrings ? */ err = get_keyblock_byfpr_fast (ctrl, &keyblock_orig, &hd, + 1 /*primary only */, fpr2, fpr2len, 1/*locked*/); if ((err && gpg_err_code (err) != GPG_ERR_NO_PUBKEY |
