From 08f0a77effeb72af4fbe0f44960c9c204799fab2 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 26 Nov 2024 16:25:57 +0100 Subject: [PATCH] Use rpmKeyringModify with RPMKEYRING_MERGE Simplify rpmtxnImportPubkey No functional change --- lib/rpmts.cc | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/lib/rpmts.cc b/lib/rpmts.cc index e01ddf92f9..649c10cb46 100644 --- a/lib/rpmts.cc +++ b/lib/rpmts.cc @@ -321,7 +321,6 @@ rpmRC rpmtxnImportPubkey(rpmtxn txn, const unsigned char * pkt, size_t pktlen) rpmRC rc = RPMRC_FAIL; /* assume failure */ char *lints = NULL; rpmPubkey pubkey = NULL; - rpmPubkey oldkey = NULL; rpmKeyring keyring = NULL; int krc; @@ -353,26 +352,13 @@ rpmRC rpmtxnImportPubkey(rpmtxn txn, const unsigned char * pkt, size_t pktlen) if ((pubkey = rpmPubkeyNew(pkt, pktlen)) == NULL) goto exit; - oldkey = rpmKeyringLookupKey(keyring, pubkey); - if (oldkey) { - rpmPubkey mergedkey = NULL; - if (rpmPubkeyMerge(oldkey, pubkey, &mergedkey) != RPMRC_OK) - goto exit; - if (!mergedkey) { - rc = RPMRC_OK; /* already have key */ - goto exit; - } - rpmPubkeyFree(pubkey); - pubkey = mergedkey; - } - - krc = rpmKeyringModify(keyring, pubkey, oldkey ? RPMKEYRING_REPLACE : RPMKEYRING_ADD); + krc = rpmKeyringModify(keyring, pubkey, RPMKEYRING_MERGE); if (krc < 0) goto exit; /* If we dont already have the key, make a persistent record of it */ if (krc == 0) { - rc = ts->keystore->import_key(txn, pubkey, oldkey ? 1 : 0); + rc = ts->keystore->import_key(txn, pubkey, 1); } else { rc = RPMRC_OK; /* already have key */ } @@ -380,7 +366,6 @@ rpmRC rpmtxnImportPubkey(rpmtxn txn, const unsigned char * pkt, size_t pktlen) exit: /* Clean up. */ rpmPubkeyFree(pubkey); - rpmPubkeyFree(oldkey); rpmKeyringFree(keyring); return rc;