From 8eff2931bee7b4aeac6f697a2eefef935bfdbbd6 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 26 Nov 2024 14:34:30 +0100 Subject: [PATCH] Fix rpmKeyringModify with RPMKEYRING_REPLACE We need to both delete the old key and add the new one. --- rpmio/rpmkeyring.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpmio/rpmkeyring.cc b/rpmio/rpmkeyring.cc index 9dd9722fdd..4b872869c7 100644 --- a/rpmio/rpmkeyring.cc +++ b/rpmio/rpmkeyring.cc @@ -167,7 +167,8 @@ int rpmKeyringModify(rpmKeyring keyring, rpmPubkey key, rpmKeyringModifyMode mod rpmPubkeyFree(item->second); keyring->keys.erase(item); rc = 0; - } else if ((item == range.second && mode == RPMKEYRING_ADD) || mode == RPMKEYRING_REPLACE) { + } + if ((item == range.second && mode == RPMKEYRING_ADD) || mode == RPMKEYRING_REPLACE) { int subkeysCount = 0; rpmPubkey *subkeys = rpmGetSubkeys(key, &subkeysCount); keyring->keys.insert({key->keyid, rpmPubkeyLink(key)});