Skip to content

Commit

Permalink
Bug 1313496 - Prevent PK11_FindSlotsByNames from double-refcounting t…
Browse files Browse the repository at this point in the history
…he internal key module r=ttaubert
  • Loading branch information
mozkeeler committed Oct 28, 2016
1 parent 34c123c commit 9a8b87e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/pk11wrap/pk11slot.c
Expand Up @@ -551,7 +551,13 @@ PK11_FindSlotsByNames(const char *dllName, const char *slotName,
((NULL == slotName) || (0 == *slotName)) &&
((NULL == tokenName) || (0 == *tokenName))) {
/* default to softoken */
PK11_AddSlotToList(slotList, PK11_GetInternalKeySlot(), PR_TRUE);
/* PK11_GetInternalKeySlot increments the refcount on the internal slot,
* but so does PK11_AddSlotToList. To avoid erroneously increasing the
* refcount twice, we get our own reference to the internal slot and
* decrement its refcount when we're done with it. */
PK11SlotInfo *internalKeySlot = PK11_GetInternalKeySlot();
PK11_AddSlotToList(slotList, internalKeySlot, PR_TRUE);
PK11_FreeSlot(internalKeySlot);
return slotList;
}

Expand Down

0 comments on commit 9a8b87e

Please sign in to comment.