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

Side by Side Diff: nss/lib/softoken/sdb.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 * This file implements PKCS 11 on top of our existing security modules 5 * This file implements PKCS 11 on top of our existing security modules
6 * 6 *
7 * For more information about PKCS 11 See PKCS 11 Token Inteface Standard. 7 * For more information about PKCS 11 See PKCS 11 Token Inteface Standard.
8 * This implementation has two slots: 8 * This implementation has two slots:
9 * slot 1 is our generic crypto support. It does not require login. 9 * slot 1 is our generic crypto support. It does not require login.
10 * It supports Public Key ops, and all they bulk ciphers and hashes. 10 * It supports Public Key ops, and all they bulk ciphers and hashes.
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 SDBFind **find) 682 SDBFind **find)
683 { 683 {
684 SDBPrivate *sdb_p = sdb->private; 684 SDBPrivate *sdb_p = sdb->private;
685 sqlite3 *sqlDB = NULL; 685 sqlite3 *sqlDB = NULL;
686 const char *table; 686 const char *table;
687 char *newStr, *findStr = NULL; 687 char *newStr, *findStr = NULL;
688 sqlite3_stmt *findstmt = NULL; 688 sqlite3_stmt *findstmt = NULL;
689 char *join=""; 689 char *join="";
690 int sqlerr = SQLITE_OK; 690 int sqlerr = SQLITE_OK;
691 CK_RV error = CKR_OK; 691 CK_RV error = CKR_OK;
692 int i; 692 unsigned int i;
693 693
694 LOCK_SQLITE() 694 LOCK_SQLITE()
695 *find = NULL; 695 *find = NULL;
696 error = sdb_openDBLocal(sdb_p, &sqlDB, &table); 696 error = sdb_openDBLocal(sdb_p, &sqlDB, &table);
697 if (error != CKR_OK) { 697 if (error != CKR_OK) {
698 goto loser; 698 goto loser;
699 } 699 }
700 700
701 findStr = sqlite3_mprintf(""); 701 findStr = sqlite3_mprintf("");
702 for (i=0; findStr && i < count; i++) { 702 for (i=0; findStr && i < count; i++) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 SDBPrivate *sdb_p = sdb->private; 829 SDBPrivate *sdb_p = sdb->private;
830 sqlite3 *sqlDB = NULL; 830 sqlite3 *sqlDB = NULL;
831 sqlite3_stmt *stmt = NULL; 831 sqlite3_stmt *stmt = NULL;
832 char *getStr = NULL; 832 char *getStr = NULL;
833 char *newStr = NULL; 833 char *newStr = NULL;
834 const char *table = NULL; 834 const char *table = NULL;
835 int sqlerr = SQLITE_OK; 835 int sqlerr = SQLITE_OK;
836 CK_RV error = CKR_OK; 836 CK_RV error = CKR_OK;
837 int found = 0; 837 int found = 0;
838 int retry = 0; 838 int retry = 0;
839 int i; 839 unsigned int i;
840 840
841 841
842 /* open a new db if necessary */ 842 /* open a new db if necessary */
843 error = sdb_openDBLocal(sdb_p, &sqlDB, &table); 843 error = sdb_openDBLocal(sdb_p, &sqlDB, &table);
844 if (error != CKR_OK) { 844 if (error != CKR_OK) {
845 goto loser; 845 goto loser;
846 } 846 }
847 847
848 for (i=0; i < count; i++) { 848 for (i=0; i < count; i++) {
849 getStr = sqlite3_mprintf("a%x", template[i].type); 849 getStr = sqlite3_mprintf("a%x", template[i].type);
(...skipping 22 matching lines...) Expand all
872 872
873 sqlerr = sqlite3_bind_int(stmt, 1, object_id); 873 sqlerr = sqlite3_bind_int(stmt, 1, object_id);
874 if (sqlerr != SQLITE_OK) { goto loser; } 874 if (sqlerr != SQLITE_OK) { goto loser; }
875 875
876 do { 876 do {
877 sqlerr = sqlite3_step(stmt); 877 sqlerr = sqlite3_step(stmt);
878 if (sqlerr == SQLITE_BUSY) { 878 if (sqlerr == SQLITE_BUSY) {
879 PR_Sleep(SDB_BUSY_RETRY_TIME); 879 PR_Sleep(SDB_BUSY_RETRY_TIME);
880 } 880 }
881 if (sqlerr == SQLITE_ROW) { 881 if (sqlerr == SQLITE_ROW) {
882 » » int blobSize; 882 » » unsigned int blobSize;
883 const char *blobData; 883 const char *blobData;
884 884
885 blobSize = sqlite3_column_bytes(stmt, 0); 885 blobSize = sqlite3_column_bytes(stmt, 0);
886 blobData = sqlite3_column_blob(stmt, 0); 886 blobData = sqlite3_column_blob(stmt, 0);
887 if (blobData == NULL) { 887 if (blobData == NULL) {
888 template[i].ulValueLen = -1; 888 template[i].ulValueLen = -1;
889 error = CKR_ATTRIBUTE_TYPE_INVALID; 889 error = CKR_ATTRIBUTE_TYPE_INVALID;
890 break; 890 break;
891 } 891 }
892 /* If the blob equals our explicit NULL value, then the 892 /* If the blob equals our explicit NULL value, then the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 const CK_ATTRIBUTE *template, CK_ULONG count) 956 const CK_ATTRIBUTE *template, CK_ULONG count)
957 { 957 {
958 SDBPrivate *sdb_p = sdb->private; 958 SDBPrivate *sdb_p = sdb->private;
959 sqlite3 *sqlDB = NULL; 959 sqlite3 *sqlDB = NULL;
960 sqlite3_stmt *stmt = NULL; 960 sqlite3_stmt *stmt = NULL;
961 char *setStr = NULL; 961 char *setStr = NULL;
962 char *newStr = NULL; 962 char *newStr = NULL;
963 int sqlerr = SQLITE_OK; 963 int sqlerr = SQLITE_OK;
964 int retry = 0; 964 int retry = 0;
965 CK_RV error = CKR_OK; 965 CK_RV error = CKR_OK;
966 int i; 966 unsigned int i;
967 967
968 if ((sdb->sdb_flags & SDB_RDONLY) != 0) { 968 if ((sdb->sdb_flags & SDB_RDONLY) != 0) {
969 return CKR_TOKEN_WRITE_PROTECTED; 969 return CKR_TOKEN_WRITE_PROTECTED;
970 } 970 }
971 971
972 if (count == 0) { 972 if (count == 0) {
973 return CKR_OK; 973 return CKR_OK;
974 } 974 }
975 975
976 LOCK_SQLITE() 976 LOCK_SQLITE()
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 SDBPrivate *sdb_p = sdb->private; 1108 SDBPrivate *sdb_p = sdb->private;
1109 sqlite3 *sqlDB = NULL; 1109 sqlite3 *sqlDB = NULL;
1110 sqlite3_stmt *stmt = NULL; 1110 sqlite3_stmt *stmt = NULL;
1111 char *columnStr = NULL; 1111 char *columnStr = NULL;
1112 char *valueStr = NULL; 1112 char *valueStr = NULL;
1113 char *newStr = NULL; 1113 char *newStr = NULL;
1114 int sqlerr = SQLITE_OK; 1114 int sqlerr = SQLITE_OK;
1115 CK_RV error = CKR_OK; 1115 CK_RV error = CKR_OK;
1116 CK_OBJECT_HANDLE this_object = CK_INVALID_HANDLE; 1116 CK_OBJECT_HANDLE this_object = CK_INVALID_HANDLE;
1117 int retry = 0; 1117 int retry = 0;
1118 int i; 1118 unsigned int i;
1119 1119
1120 if ((sdb->sdb_flags & SDB_RDONLY) != 0) { 1120 if ((sdb->sdb_flags & SDB_RDONLY) != 0) {
1121 return CKR_TOKEN_WRITE_PROTECTED; 1121 return CKR_TOKEN_WRITE_PROTECTED;
1122 } 1122 }
1123 1123
1124 LOCK_SQLITE() 1124 LOCK_SQLITE()
1125 if ((*object_id != CK_INVALID_HANDLE) && 1125 if ((*object_id != CK_INVALID_HANDLE) &&
1126 !sdb_objectExists(sdb, *object_id)) { 1126 !sdb_objectExists(sdb, *object_id)) {
1127 this_object = *object_id; 1127 this_object = *object_id;
1128 } else { 1128 } else {
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 s_shutdown() 2078 s_shutdown()
2079 { 2079 {
2080 #ifdef SQLITE_UNSAFE_THREADS 2080 #ifdef SQLITE_UNSAFE_THREADS
2081 if (sqlite_lock) { 2081 if (sqlite_lock) {
2082 PR_DestroyLock(sqlite_lock); 2082 PR_DestroyLock(sqlite_lock);
2083 sqlite_lock = NULL; 2083 sqlite_lock = NULL;
2084 } 2084 }
2085 #endif 2085 #endif
2086 return CKR_OK; 2086 return CKR_OK;
2087 } 2087 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698