Skip to content

Commit

Permalink
catch non-present tokens before searching them
Browse files Browse the repository at this point in the history
  • Loading branch information
ian.mcgreer%sun.com committed Apr 18, 2002
1 parent 2efbc5e commit 8f5cf32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion security/nss/lib/pk11wrap/pk11cert.c
Expand Up @@ -2540,6 +2540,9 @@ PK11_TraverseCertsForSubjectInSlot(CERTCertificate *cert, PK11SlotInfo *slot,
td = STAN_GetDefaultTrustDomain();
NSSITEM_FROM_SECITEM(&subject, &cert->derSubject);
token = PK11Slot_GetNSSToken(slot);
if (!nssToken_IsPresent(token)) {
return SECSuccess;
}
collection = nssCertificateCollection_Create(td, NULL);
if (!collection) {
return SECFailure;
Expand Down Expand Up @@ -2627,6 +2630,10 @@ PK11_TraverseCertsForNicknameInSlot(SECItem *nickname, PK11SlotInfo *slot,
nssTokenSearchType tokenOnly = nssTokenSearchType_TokenOnly;
pk11cb.callback = callback;
pk11cb.arg = arg;
token = PK11Slot_GetNSSToken(slot);
if (!nssToken_IsPresent(token)) {
return SECSuccess;
}
if (nickname->data[nickname->len-1] != '\0') {
nick = nssUTF8_Create(NULL, nssStringType_UTF8String,
nickname->data, nickname->len);
Expand All @@ -2635,7 +2642,6 @@ PK11_TraverseCertsForNicknameInSlot(SECItem *nickname, PK11SlotInfo *slot,
nick = (NSSUTF8 *)nickname->data;
}
td = STAN_GetDefaultTrustDomain();
token = PK11Slot_GetNSSToken(slot);
collection = nssCertificateCollection_Create(td, NULL);
if (!collection) {
goto loser;
Expand Down Expand Up @@ -2722,6 +2728,9 @@ PK11_TraverseCertsInSlot(PK11SlotInfo *slot,
NSSCertificate **certs;
nssTokenSearchType tokenOnly = nssTokenSearchType_TokenOnly;
tok = PK11Slot_GetNSSToken(slot);
if (!nssToken_IsPresent(tok)) {
return SECSuccess;
}
collection = nssCertificateCollection_Create(td, NULL);
if (!collection) {
return SECFailure;
Expand Down
6 changes: 4 additions & 2 deletions security/nss/lib/pki/trustdomain.c
Expand Up @@ -285,8 +285,10 @@ NSSTrustDomain_FindTokenByName
tok != (NSSToken *)NULL;
tok = (NSSToken *)nssListIterator_Next(td->tokens))
{
myName = nssToken_GetName(tok);
if (nssUTF8_Equal(tokenName, myName, &nssrv)) break;
if (nssToken_IsPresent(tok)) {
myName = nssToken_GetName(tok);
if (nssUTF8_Equal(tokenName, myName, &nssrv)) break;
}
}
nssListIterator_Finish(td->tokens);
return tok;
Expand Down

0 comments on commit 8f5cf32

Please sign in to comment.