[Rpm-maint] [rpm-software-management/rpm] Handle subkeys in rpmKeyringModify (PR #3403)

Florian Festi notifications at github.com
Thu Oct 24 13:17:37 UTC 2024


@ffesti commented on this pull request.



> @@ -133,16 +133,32 @@ int rpmKeyringModify(rpmKeyring keyring, rpmPubkey key, rpmKeyringModifyMode mod
 	if (item->second->fp == key->fp)
 	    break;
     }
-    if (item != range.second && mode == RPMKEYRING_DELETE) {
+    if (item != range.second && (mode == RPMKEYRING_DELETE || mode == RPMKEYRING_REPLACE)) {
+	/* remove sub keys */
+	for (auto it = keyring->keys.begin(); it != keyring->keys.end();) {
+	    if (it->second->primarykey == item->second) {
+		rpmPubkeyFree(it->second);
+		it = keyring->keys.erase(it);
+	    } else {
+		++it;

Well in C `for` loops are `while` loops with fancy decorations. I find using a for loop much more clear as it indicates that we are looping over all items in order. If I see a while loop this could do anything.

Not that I care much, changed.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3403#discussion_r1814975098
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/3403/review/2392485245 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20241024/52191000/attachment.html>


More information about the Rpm-maint mailing list