Skip to content

Commit

Permalink
Lock key during rpmGetSubkeys()
Browse files Browse the repository at this point in the history
This should be thread save as it still is in the public API. The
internal use would be fine otherwise. So the lock can be removed if this
gets made internal only.

Resolves: rpm-software-management#3351
  • Loading branch information
ffesti committed Oct 8, 2024
1 parent a45134e commit 8d4dd6d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rpmio/rpmkeyring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ rpmPubkey *rpmGetSubkeys(rpmPubkey primarykey, int *count)
int pgpsubkeysCount = 0;
int i;

if (primarykey && !pgpPrtParamsSubkeys(primarykey->pkt.data(), primarykey->pkt.size(),
if (!primarykey)
return NULL;

rdlock lock(primarykey->mutex);

if (!pgpPrtParamsSubkeys(primarykey->pkt.data(), primarykey->pkt.size(),
primarykey->pgpkey, &pgpsubkeys, &pgpsubkeysCount)) {
/* Returned to C, can't use new */
subkeys = (rpmPubkey *)xmalloc(pgpsubkeysCount * sizeof(*subkeys));
Expand Down

0 comments on commit 8d4dd6d

Please sign in to comment.