Skip to content

Commit

Permalink
overwrite old entry during import, so that changing trust works corre…
Browse files Browse the repository at this point in the history
…ctly
  • Loading branch information
ian.mcgreer%sun.com committed Apr 22, 2002
1 parent f312596 commit 775843f
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions security/nss/lib/dev/devutil.c
Expand Up @@ -1268,6 +1268,7 @@ nssTokenObjectCache_ImportObject
PRUint32 count;
nssCryptokiObjectAndAttributes **oa, ***otype;
PRUint32 objectType;
PRBool haveIt = PR_FALSE;
PZ_Lock(cache->lock);
switch (objclass) {
case CKO_CERTIFICATE: objectType = cachedCerts; break;
Expand All @@ -1284,13 +1285,28 @@ nssTokenObjectCache_ImportObject
count = 0;
otype = &cache->objects[objectType]; /* index into array of types */
oa = *otype; /* the array of objects for this type */
while (oa && *oa++) count++;
if (count > 0) {
*otype = nss_ZREALLOCARRAY(*otype,
nssCryptokiObjectAndAttributes *,
count + 2);
while (oa && *oa) {
if (nssCryptokiObject_Equal((*oa)->object, object)) {
haveIt = PR_TRUE;
break;
}
count++;
oa++;
}
if (haveIt) {
/* Destroy the old entry */
(*oa)->object->token = NULL;
nssCryptokiObject_Destroy((*oa)->object);
nssArena_Destroy((*oa)->arena);
} else {
*otype = nss_ZNEWARRAY(NULL, nssCryptokiObjectAndAttributes *, 2);
/* Create space for a new entry */
if (count > 0) {
*otype = nss_ZREALLOCARRAY(*otype,
nssCryptokiObjectAndAttributes *,
count + 2);
} else {
*otype = nss_ZNEWARRAY(NULL, nssCryptokiObjectAndAttributes *, 2);
}
}
if (*otype) {
nssCryptokiObject *copyObject = nssCryptokiObject_Clone(object);
Expand Down

0 comments on commit 775843f

Please sign in to comment.