Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: nss/lib/softoken/sftkdb.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 /* 4 /*
5 * The following code handles the storage of PKCS 11 modules used by the 5 * The following code handles the storage of PKCS 11 modules used by the
6 * NSS. For the rest of NSS, only one kind of database handle exists: 6 * NSS. For the rest of NSS, only one kind of database handle exists:
7 * 7 *
8 * SFTKDBHandle 8 * SFTKDBHandle
9 * 9 *
10 * There is one SFTKDBHandle for the each key database and one for each cert 10 * There is one SFTKDBHandle for the each key database and one for each cert
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 318 }
319 319
320 for (i=0; i < count; i++) { 320 for (i=0; i < count; i++) {
321 CK_ULONG length = template[i].ulValueLen; 321 CK_ULONG length = template[i].ulValueLen;
322 template[i].ulValueLen = ntemplate[i].ulValueLen; 322 template[i].ulValueLen = ntemplate[i].ulValueLen;
323 /* fixup ulongs */ 323 /* fixup ulongs */
324 if (ntemplate[i].ulValueLen == SDB_ULONG_SIZE) { 324 if (ntemplate[i].ulValueLen == SDB_ULONG_SIZE) {
325 if (sftkdb_isULONGAttribute(template[i].type)) { 325 if (sftkdb_isULONGAttribute(template[i].type)) {
326 if (template[i].pValue) { 326 if (template[i].pValue) {
327 CK_ULONG value; 327 CK_ULONG value;
328 unsigned char *data;
329 328
330 data = (unsigned char *)ntemplate[i].pValue;
331 value = sftk_SDBULong2ULong(ntemplate[i].pValue); 329 value = sftk_SDBULong2ULong(ntemplate[i].pValue);
332 if (length < sizeof(CK_ULONG)) { 330 if (length < sizeof(CK_ULONG)) {
333 template[i].ulValueLen = -1; 331 template[i].ulValueLen = -1;
334 crv = CKR_BUFFER_TOO_SMALL; 332 crv = CKR_BUFFER_TOO_SMALL;
335 continue; 333 continue;
336 } 334 }
337 PORT_Memcpy(template[i].pValue,&value,sizeof(CK_ULONG)); 335 PORT_Memcpy(template[i].pValue,&value,sizeof(CK_ULONG));
338 } 336 }
339 template[i].ulValueLen = sizeof(CK_ULONG); 337 template[i].ulValueLen = sizeof(CK_ULONG);
340 } 338 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 * 466 *
469 * The caller is expected to abort any transaction he was in in the 467 * The caller is expected to abort any transaction he was in in the
470 * event of a failure of this function. 468 * event of a failure of this function.
471 */ 469 */
472 static CK_RV 470 static CK_RV
473 sftk_signTemplate(PLArenaPool *arena, SFTKDBHandle *handle, 471 sftk_signTemplate(PLArenaPool *arena, SFTKDBHandle *handle,
474 PRBool mayBeUpdateDB, 472 PRBool mayBeUpdateDB,
475 CK_OBJECT_HANDLE objectID, const CK_ATTRIBUTE *template, 473 CK_OBJECT_HANDLE objectID, const CK_ATTRIBUTE *template,
476 CK_ULONG count) 474 CK_ULONG count)
477 { 475 {
478 int i; 476 unsigned int i;
479 CK_RV crv; 477 CK_RV crv;
480 SFTKDBHandle *keyHandle = handle; 478 SFTKDBHandle *keyHandle = handle;
481 SDB *keyTarget = NULL; 479 SDB *keyTarget = NULL;
482 PRBool usingPeerDB = PR_FALSE; 480 PRBool usingPeerDB = PR_FALSE;
483 PRBool inPeerDBTransaction = PR_FALSE; 481 PRBool inPeerDBTransaction = PR_FALSE;
484 482
485 PORT_Assert(handle); 483 PORT_Assert(handle);
486 484
487 if (handle->type != SFTK_KEYDB_TYPE) { 485 if (handle->type != SFTK_KEYDB_TYPE) {
488 keyHandle = handle->peerDB; 486 keyHandle = handle->peerDB;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 if (crv == CKR_OK) crv = CKR_GENERAL_ERROR; 564 if (crv == CKR_OK) crv = CKR_GENERAL_ERROR;
567 } 565 }
568 return crv; 566 return crv;
569 } 567 }
570 568
571 static CK_RV 569 static CK_RV
572 sftkdb_CreateObject(PLArenaPool *arena, SFTKDBHandle *handle, 570 sftkdb_CreateObject(PLArenaPool *arena, SFTKDBHandle *handle,
573 SDB *db, CK_OBJECT_HANDLE *objectID, 571 SDB *db, CK_OBJECT_HANDLE *objectID,
574 CK_ATTRIBUTE *template, CK_ULONG count) 572 CK_ATTRIBUTE *template, CK_ULONG count)
575 { 573 {
576 PRBool inTransaction = PR_FALSE;
577 CK_RV crv; 574 CK_RV crv;
578 575
579 inTransaction = PR_TRUE;
580
581 crv = (*db->sdb_CreateObject)(db, objectID, template, count); 576 crv = (*db->sdb_CreateObject)(db, objectID, template, count);
582 if (crv != CKR_OK) { 577 if (crv != CKR_OK) {
583 goto loser; 578 goto loser;
584 } 579 }
585 crv = sftk_signTemplate(arena, handle, (db == handle->update), 580 crv = sftk_signTemplate(arena, handle, (db == handle->update),
586 *objectID, template, count); 581 *objectID, template, count);
587 loser: 582 loser:
588 583
589 return crv; 584 return crv;
590 } 585 }
591 586
592 587
593 CK_ATTRIBUTE * 588 CK_ATTRIBUTE *
594 sftk_ExtractTemplate(PLArenaPool *arena, SFTKObject *object, 589 sftk_ExtractTemplate(PLArenaPool *arena, SFTKObject *object,
595 SFTKDBHandle *handle,CK_ULONG *pcount, 590 SFTKDBHandle *handle,CK_ULONG *pcount,
596 CK_RV *crv) 591 CK_RV *crv)
597 { 592 {
598 int count; 593 unsigned int count;
599 CK_ATTRIBUTE *template; 594 CK_ATTRIBUTE *template;
600 int i, templateIndex; 595 unsigned int i, templateIndex;
601 SFTKSessionObject *sessObject = sftk_narrowToSessionObject(object); 596 SFTKSessionObject *sessObject = sftk_narrowToSessionObject(object);
602 PRBool doEnc = PR_TRUE; 597 PRBool doEnc = PR_TRUE;
603 598
604 *crv = CKR_OK; 599 *crv = CKR_OK;
605 600
606 if (sessObject == NULL) { 601 if (sessObject == NULL) {
607 *crv = CKR_GENERAL_ERROR; /* internal programming error */ 602 *crv = CKR_GENERAL_ERROR; /* internal programming error */
608 return NULL; 603 return NULL;
609 } 604 }
610 605
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 * Changes must be made in both copies. 1009 * Changes must be made in both copies.
1015 * The other copy is in pk11_IncrementNickname() in pk11wrap/pk11merge.c. 1010 * The other copy is in pk11_IncrementNickname() in pk11wrap/pk11merge.c.
1016 * 1011 *
1017 */ 1012 */
1018 static CK_RV 1013 static CK_RV
1019 sftkdb_resolveConflicts(PLArenaPool *arena, CK_OBJECT_CLASS objectType, 1014 sftkdb_resolveConflicts(PLArenaPool *arena, CK_OBJECT_CLASS objectType,
1020 CK_ATTRIBUTE *ptemplate, CK_ULONG *plen) 1015 CK_ATTRIBUTE *ptemplate, CK_ULONG *plen)
1021 { 1016 {
1022 CK_ATTRIBUTE *attr; 1017 CK_ATTRIBUTE *attr;
1023 char *nickname, *newNickname; 1018 char *nickname, *newNickname;
1024 int end, digit; 1019 unsigned int end, digit;
1025 1020
1026 /* sanity checks. We should never get here with these errors */ 1021 /* sanity checks. We should never get here with these errors */
1027 if (objectType != CKO_CERTIFICATE) { 1022 if (objectType != CKO_CERTIFICATE) {
1028 return CKR_GENERAL_ERROR; /* shouldn't happen */ 1023 return CKR_GENERAL_ERROR; /* shouldn't happen */
1029 } 1024 }
1030 attr = sftkdb_getAttributeFromTemplate(CKA_LABEL, ptemplate, *plen); 1025 attr = sftkdb_getAttributeFromTemplate(CKA_LABEL, ptemplate, *plen);
1031 if ((attr == NULL) || (attr->ulValueLen == 0)) { 1026 if ((attr == NULL) || (attr->ulValueLen == 0)) {
1032 return CKR_GENERAL_ERROR; /* shouldn't happen */ 1027 return CKR_GENERAL_ERROR; /* shouldn't happen */
1033 } 1028 }
1034 1029
(...skipping 18 matching lines...) Expand all
1053 if (!newNickname) { 1048 if (!newNickname) {
1054 return CKR_HOST_MEMORY; 1049 return CKR_HOST_MEMORY;
1055 } 1050 }
1056 PORT_Memcpy(newNickname, nickname, attr->ulValueLen); 1051 PORT_Memcpy(newNickname, nickname, attr->ulValueLen);
1057 PORT_Memcpy(&newNickname[attr->ulValueLen], num2, sizeof(num2)); 1052 PORT_Memcpy(&newNickname[attr->ulValueLen], num2, sizeof(num2));
1058 attr->pValue = newNickname; /* modifies ptemplate */ 1053 attr->pValue = newNickname; /* modifies ptemplate */
1059 attr->ulValueLen += 3; /* 3 is strlen(num2) */ 1054 attr->ulValueLen += 3; /* 3 is strlen(num2) */
1060 return CKR_OK; 1055 return CKR_OK;
1061 } 1056 }
1062 1057
1063 for (end = attr->ulValueLen - 1; 1058 for (end = attr->ulValueLen; end-- > 0;) {
1064 » end >= 0 && (digit = nickname[end]) <= '9' && digit >= '0'; 1059 » digit = nickname[end];
1065 » end--) { 1060 if (digit > '9' || digit < '0') {
1061 » break;
1062 }
1066 if (digit < '9') { 1063 if (digit < '9') {
1067 nickname[end]++; 1064 nickname[end]++;
1068 return CKR_OK; 1065 return CKR_OK;
1069 } 1066 }
1070 nickname[end] = '0'; 1067 nickname[end] = '0';
1071 } 1068 }
1072 1069
1073 /* we overflowed, insert a new '1' for a carry in front of the number */ 1070 /* we overflowed, insert a new '1' for a carry in front of the number */
1074 newNickname = PORT_ArenaAlloc(arena, attr->ulValueLen + 1); 1071 newNickname = PORT_ArenaAlloc(arena, attr->ulValueLen + 1);
1075 if (!newNickname) { 1072 if (!newNickname) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1247
1251 if (handle == NULL) { 1248 if (handle == NULL) {
1252 *count = 0; 1249 *count = 0;
1253 return CKR_OK; 1250 return CKR_OK;
1254 } 1251 }
1255 db = SFTK_GET_SDB(handle); 1252 db = SFTK_GET_SDB(handle);
1256 1253
1257 crv = (*db->sdb_FindObjects)(db, find, ids, 1254 crv = (*db->sdb_FindObjects)(db, find, ids,
1258 arraySize, count); 1255 arraySize, count);
1259 if (crv == CKR_OK) { 1256 if (crv == CKR_OK) {
1260 » int i; 1257 » unsigned int i;
1261 for (i=0; i < *count; i++) { 1258 for (i=0; i < *count; i++) {
1262 ids[i] |= (handle->type | SFTK_TOKEN_TYPE); 1259 ids[i] |= (handle->type | SFTK_TOKEN_TYPE);
1263 } 1260 }
1264 } 1261 }
1265 return crv; 1262 return crv;
1266 } 1263 }
1267 1264
1268 CK_RV sftkdb_FindObjectsFinal(SFTKDBHandle *handle, SDBFind *find) 1265 CK_RV sftkdb_FindObjectsFinal(SFTKDBHandle *handle, SDBFind *find)
1269 { 1266 {
1270 SDB *db; 1267 SDB *db;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 CKA_TRUST_DIGITAL_SIGNATURE, CKA_TRUST_NON_REPUDIATION, 1590 CKA_TRUST_DIGITAL_SIGNATURE, CKA_TRUST_NON_REPUDIATION,
1594 CKA_TRUST_KEY_ENCIPHERMENT, CKA_TRUST_DATA_ENCIPHERMENT, 1591 CKA_TRUST_KEY_ENCIPHERMENT, CKA_TRUST_DATA_ENCIPHERMENT,
1595 CKA_TRUST_KEY_AGREEMENT, CKA_TRUST_KEY_CERT_SIGN, CKA_TRUST_CRL_SIGN, 1592 CKA_TRUST_KEY_AGREEMENT, CKA_TRUST_KEY_CERT_SIGN, CKA_TRUST_CRL_SIGN,
1596 CKA_TRUST_SERVER_AUTH, CKA_TRUST_CLIENT_AUTH, CKA_TRUST_CODE_SIGNING, 1593 CKA_TRUST_SERVER_AUTH, CKA_TRUST_CLIENT_AUTH, CKA_TRUST_CODE_SIGNING,
1597 CKA_TRUST_EMAIL_PROTECTION, CKA_TRUST_IPSEC_END_SYSTEM, 1594 CKA_TRUST_EMAIL_PROTECTION, CKA_TRUST_IPSEC_END_SYSTEM,
1598 CKA_TRUST_IPSEC_TUNNEL, CKA_TRUST_IPSEC_USER, CKA_TRUST_TIME_STAMPING, 1595 CKA_TRUST_IPSEC_TUNNEL, CKA_TRUST_IPSEC_USER, CKA_TRUST_TIME_STAMPING,
1599 CKA_TRUST_STEP_UP_APPROVED, CKA_CERT_SHA1_HASH, CKA_CERT_MD5_HASH, 1596 CKA_TRUST_STEP_UP_APPROVED, CKA_CERT_SHA1_HASH, CKA_CERT_MD5_HASH,
1600 CKA_NETSCAPE_DB, CKA_NETSCAPE_TRUST, CKA_NSS_OVERRIDE_EXTENSIONS 1597 CKA_NETSCAPE_DB, CKA_NETSCAPE_TRUST, CKA_NSS_OVERRIDE_EXTENSIONS
1601 }; 1598 };
1602 1599
1603 static int known_attributes_size= sizeof(known_attributes)/ 1600 static unsigned int known_attributes_size= sizeof(known_attributes)/
1604 sizeof(known_attributes[0]); 1601 sizeof(known_attributes[0]);
1605 1602
1606 static CK_RV 1603 static CK_RV
1607 sftkdb_GetObjectTemplate(SDB *source, CK_OBJECT_HANDLE id, 1604 sftkdb_GetObjectTemplate(SDB *source, CK_OBJECT_HANDLE id,
1608 CK_ATTRIBUTE *ptemplate, CK_ULONG *max) 1605 CK_ATTRIBUTE *ptemplate, CK_ULONG *max)
1609 { 1606 {
1610 int i,j; 1607 unsigned int i,j;
1611 CK_RV crv; 1608 CK_RV crv;
1612 1609
1613 if (*max < known_attributes_size) { 1610 if (*max < known_attributes_size) {
1614 *max = known_attributes_size; 1611 *max = known_attributes_size;
1615 return CKR_BUFFER_TOO_SMALL; 1612 return CKR_BUFFER_TOO_SMALL;
1616 } 1613 }
1617 for (i=0; i < known_attributes_size; i++) { 1614 for (i=0; i < known_attributes_size; i++) {
1618 ptemplate[i].type = known_attributes[i]; 1615 ptemplate[i].type = known_attributes[i];
1619 ptemplate[i].pValue = NULL; 1616 ptemplate[i].pValue = NULL;
1620 ptemplate[i].ulValueLen = 0; 1617 ptemplate[i].ulValueLen = 0;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 static sftkdbUpdateStatus 2001 static sftkdbUpdateStatus
2005 sftkdb_handleIDAndName(PLArenaPool *arena, SDB *db, CK_OBJECT_HANDLE id, 2002 sftkdb_handleIDAndName(PLArenaPool *arena, SDB *db, CK_OBJECT_HANDLE id,
2006 CK_ATTRIBUTE *ptemplate, CK_ULONG *plen) 2003 CK_ATTRIBUTE *ptemplate, CK_ULONG *plen)
2007 { 2004 {
2008 sftkdbUpdateStatus update = SFTKDB_DO_NOTHING; 2005 sftkdbUpdateStatus update = SFTKDB_DO_NOTHING;
2009 CK_ATTRIBUTE *attr1, *attr2; 2006 CK_ATTRIBUTE *attr1, *attr2;
2010 CK_ATTRIBUTE ttemplate[2] = { 2007 CK_ATTRIBUTE ttemplate[2] = {
2011 {CKA_ID, NULL, 0}, 2008 {CKA_ID, NULL, 0},
2012 {CKA_LABEL, NULL, 0} 2009 {CKA_LABEL, NULL, 0}
2013 }; 2010 };
2014 CK_RV crv;
2015 2011
2016 attr1 = sftkdb_getAttributeFromTemplate(CKA_LABEL, ptemplate, *plen); 2012 attr1 = sftkdb_getAttributeFromTemplate(CKA_LABEL, ptemplate, *plen);
2017 attr2 = sftkdb_getAttributeFromTemplate(CKA_ID, ptemplate, *plen); 2013 attr2 = sftkdb_getAttributeFromTemplate(CKA_ID, ptemplate, *plen);
2018 2014
2019 /* if the source has neither an id nor label, don't bother updating */ 2015 /* if the source has neither an id nor label, don't bother updating */
2020 if ( (!attr1 || attr1->ulValueLen == 0) && 2016 if ( (!attr1 || attr1->ulValueLen == 0) &&
2021 (! attr2 || attr2->ulValueLen == 0) ) { 2017 (! attr2 || attr2->ulValueLen == 0) ) {
2022 return SFTKDB_DO_NOTHING; 2018 return SFTKDB_DO_NOTHING;
2023 } 2019 }
2024 2020
2025 /* the source has either an id or a label, see what the target has */ 2021 /* the source has either an id or a label, see what the target has */
2026 crv = (*db->sdb_GetAttributeValue)(db, id, ttemplate, 2); 2022 (void)(*db->sdb_GetAttributeValue)(db, id, ttemplate, 2);
2027 2023
2028 /* if the target has neither, update from the source */ 2024 /* if the target has neither, update from the source */
2029 if ( ((ttemplate[0].ulValueLen == 0) || 2025 if ( ((ttemplate[0].ulValueLen == 0) ||
2030 (ttemplate[0].ulValueLen == (CK_ULONG)-1)) && 2026 (ttemplate[0].ulValueLen == (CK_ULONG)-1)) &&
2031 ((ttemplate[1].ulValueLen == 0) || 2027 ((ttemplate[1].ulValueLen == 0) ||
2032 (ttemplate[1].ulValueLen == (CK_ULONG)-1)) ) { 2028 (ttemplate[1].ulValueLen == (CK_ULONG)-1)) ) {
2033 return SFTKDB_MODIFY_OBJECT; 2029 return SFTKDB_MODIFY_OBJECT;
2034 } 2030 }
2035 2031
2036 /* check the CKA_ID */ 2032 /* check the CKA_ID */
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 static CK_RV 2157 static CK_RV
2162 sftkdb_mergeObject(SFTKDBHandle *handle, CK_OBJECT_HANDLE id, 2158 sftkdb_mergeObject(SFTKDBHandle *handle, CK_OBJECT_HANDLE id,
2163 SECItem *key) 2159 SECItem *key)
2164 { 2160 {
2165 CK_ATTRIBUTE template[MAX_ATTRIBUTES]; 2161 CK_ATTRIBUTE template[MAX_ATTRIBUTES];
2166 CK_ATTRIBUTE *ptemplate; 2162 CK_ATTRIBUTE *ptemplate;
2167 CK_ULONG max_attributes = MAX_ATTRIBUTES; 2163 CK_ULONG max_attributes = MAX_ATTRIBUTES;
2168 CK_OBJECT_CLASS objectType; 2164 CK_OBJECT_CLASS objectType;
2169 SDB *source = handle->update; 2165 SDB *source = handle->update;
2170 SDB *target = handle->db; 2166 SDB *target = handle->db;
2171 int i; 2167 unsigned int i;
2172 CK_RV crv; 2168 CK_RV crv;
2173 PLArenaPool *arena = NULL; 2169 PLArenaPool *arena = NULL;
2174 2170
2175 arena = PORT_NewArena(256); 2171 arena = PORT_NewArena(256);
2176 if (arena == NULL) { 2172 if (arena == NULL) {
2177 return CKR_HOST_MEMORY; 2173 return CKR_HOST_MEMORY;
2178 } 2174 }
2179 2175
2180 ptemplate = &template[0]; 2176 ptemplate = &template[0];
2181 id &= SFTK_OBJ_ID_MASK; 2177 id &= SFTK_OBJ_ID_MASK;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 */ 2246 */
2251 CK_RV 2247 CK_RV
2252 sftkdb_Update(SFTKDBHandle *handle, SECItem *key) 2248 sftkdb_Update(SFTKDBHandle *handle, SECItem *key)
2253 { 2249 {
2254 SDBFind *find = NULL; 2250 SDBFind *find = NULL;
2255 CK_ULONG idCount = MAX_IDS; 2251 CK_ULONG idCount = MAX_IDS;
2256 CK_OBJECT_HANDLE ids[MAX_IDS]; 2252 CK_OBJECT_HANDLE ids[MAX_IDS];
2257 SECItem *updatePasswordKey = NULL; 2253 SECItem *updatePasswordKey = NULL;
2258 CK_RV crv, crv2; 2254 CK_RV crv, crv2;
2259 PRBool inTransaction = PR_FALSE; 2255 PRBool inTransaction = PR_FALSE;
2260 int i; 2256 unsigned int i;
2261 2257
2262 if (handle == NULL) { 2258 if (handle == NULL) {
2263 return CKR_OK; 2259 return CKR_OK;
2264 } 2260 }
2265 if (handle->update == NULL) { 2261 if (handle->update == NULL) {
2266 return CKR_OK; 2262 return CKR_OK;
2267 } 2263 }
2268 2264
2269 /* 2265 /*
2270 * put the whole update under a transaction. This allows us to handle 2266 * put the whole update under a transaction. This allows us to handle
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 * (database for public objects) 2401 * (database for public objects)
2406 */ 2402 */
2407 SFTKDBHandle * 2403 SFTKDBHandle *
2408 sftk_getCertDB(SFTKSlot *slot) 2404 sftk_getCertDB(SFTKSlot *slot)
2409 { 2405 {
2410 SFTKDBHandle *dbHandle; 2406 SFTKDBHandle *dbHandle;
2411 2407
2412 PZ_Lock(slot->slotLock); 2408 PZ_Lock(slot->slotLock);
2413 dbHandle = slot->certDB; 2409 dbHandle = slot->certDB;
2414 if (dbHandle) { 2410 if (dbHandle) {
2415 PR_ATOMIC_INCREMENT(&dbHandle->ref); 2411 (void)PR_ATOMIC_INCREMENT(&dbHandle->ref);
2416 } 2412 }
2417 PZ_Unlock(slot->slotLock); 2413 PZ_Unlock(slot->slotLock);
2418 return dbHandle; 2414 return dbHandle;
2419 } 2415 }
2420 2416
2421 /* 2417 /*
2422 * acquire a database handle for a key database 2418 * acquire a database handle for a key database
2423 * (database for private objects) 2419 * (database for private objects)
2424 */ 2420 */
2425 SFTKDBHandle * 2421 SFTKDBHandle *
2426 sftk_getKeyDB(SFTKSlot *slot) 2422 sftk_getKeyDB(SFTKSlot *slot)
2427 { 2423 {
2428 SFTKDBHandle *dbHandle; 2424 SFTKDBHandle *dbHandle;
2429 2425
2430 SKIP_AFTER_FORK(PZ_Lock(slot->slotLock)); 2426 SKIP_AFTER_FORK(PZ_Lock(slot->slotLock));
2431 dbHandle = slot->keyDB; 2427 dbHandle = slot->keyDB;
2432 if (dbHandle) { 2428 if (dbHandle) {
2433 PR_ATOMIC_INCREMENT(&dbHandle->ref); 2429 (void)PR_ATOMIC_INCREMENT(&dbHandle->ref);
2434 } 2430 }
2435 SKIP_AFTER_FORK(PZ_Unlock(slot->slotLock)); 2431 SKIP_AFTER_FORK(PZ_Unlock(slot->slotLock));
2436 return dbHandle; 2432 return dbHandle;
2437 } 2433 }
2438 2434
2439 /* 2435 /*
2440 * acquire the database for a specific object. NOTE: objectID must point 2436 * acquire the database for a specific object. NOTE: objectID must point
2441 * to a Token object! 2437 * to a Token object!
2442 */ 2438 */
2443 SFTKDBHandle * 2439 SFTKDBHandle *
2444 sftk_getDBForTokenObject(SFTKSlot *slot, CK_OBJECT_HANDLE objectID) 2440 sftk_getDBForTokenObject(SFTKSlot *slot, CK_OBJECT_HANDLE objectID)
2445 { 2441 {
2446 SFTKDBHandle *dbHandle; 2442 SFTKDBHandle *dbHandle;
2447 2443
2448 PZ_Lock(slot->slotLock); 2444 PZ_Lock(slot->slotLock);
2449 dbHandle = objectID & SFTK_KEYDB_TYPE ? slot->keyDB : slot->certDB; 2445 dbHandle = objectID & SFTK_KEYDB_TYPE ? slot->keyDB : slot->certDB;
2450 if (dbHandle) { 2446 if (dbHandle) {
2451 PR_ATOMIC_INCREMENT(&dbHandle->ref); 2447 (void)PR_ATOMIC_INCREMENT(&dbHandle->ref);
2452 } 2448 }
2453 PZ_Unlock(slot->slotLock); 2449 PZ_Unlock(slot->slotLock);
2454 return dbHandle; 2450 return dbHandle;
2455 } 2451 }
2456 2452
2457 /* 2453 /*
2458 * initialize a new database handle 2454 * initialize a new database handle
2459 */ 2455 */
2460 static SFTKDBHandle * 2456 static SFTKDBHandle *
2461 sftk_NewDBHandle(SDB *sdb, int type) 2457 sftk_NewDBHandle(SDB *sdb, int type)
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2728 } 2724 }
2729 2725
2730 CK_RV 2726 CK_RV
2731 sftkdb_Shutdown(void) 2727 sftkdb_Shutdown(void)
2732 { 2728 {
2733 s_shutdown(); 2729 s_shutdown();
2734 sftkdbCall_Shutdown(); 2730 sftkdbCall_Shutdown();
2735 return CKR_OK; 2731 return CKR_OK;
2736 } 2732 }
2737 2733
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698