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

Unified Diff: nss/mozilla/security/nss/lib/softoken/sdb.c

Issue 3536010: Update to NSS 3.12.8. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « nss/mozilla/security/nss/lib/softoken/sdb.h ('k') | nss/mozilla/security/nss/lib/softoken/softkver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nss/mozilla/security/nss/lib/softoken/sdb.c
===================================================================
--- nss/mozilla/security/nss/lib/softoken/sdb.c (revision 61548)
+++ nss/mozilla/security/nss/lib/softoken/sdb.c (working copy)
@@ -827,51 +827,49 @@
goto loser;
}
- getStr = sqlite3_mprintf("");
- for (i=0; getStr && i < count; i++) {
- if (i==0) {
- newStr = sqlite3_mprintf("a%x", template[i].type);
- } else {
- newStr = sqlite3_mprintf("%s, a%x", getStr, template[i].type);
+ for (i=0; i < count; i++) {
+ getStr = sqlite3_mprintf("a%x", template[i].type);
+
+ if (getStr == NULL) {
+ error = CKR_HOST_MEMORY;
+ goto loser;
}
+
+ newStr = sqlite3_mprintf(GET_ATTRIBUTE_CMD, getStr, table);
sqlite3_free(getStr);
- getStr = newStr;
- }
+ getStr = NULL;
+ if (newStr == NULL) {
+ error = CKR_HOST_MEMORY;
+ goto loser;
+ }
- if (getStr == NULL) {
- error = CKR_HOST_MEMORY;
- goto loser;
- }
+ sqlerr = sqlite3_prepare_v2(sqlDB, newStr, -1, &stmt, NULL);
+ sqlite3_free(newStr);
+ newStr = NULL;
+ if (sqlerr == SQLITE_ERROR) {
+ template[i].ulValueLen = -1;
+ error = CKR_ATTRIBUTE_TYPE_INVALID;
+ continue;
+ } else if (sqlerr != SQLITE_OK) { goto loser; }
- newStr = sqlite3_mprintf(GET_ATTRIBUTE_CMD, getStr, table);
- sqlite3_free(getStr);
- getStr = NULL;
- if (newStr == NULL) {
- error = CKR_HOST_MEMORY;
- goto loser;
- }
+ sqlerr = sqlite3_bind_int(stmt, 1, object_id);
+ if (sqlerr != SQLITE_OK) { goto loser; }
- sqlerr = sqlite3_prepare_v2(sqlDB, newStr, -1, &stmt, NULL);
- if (sqlerr != SQLITE_OK) { goto loser; }
- sqlerr = sqlite3_bind_int(stmt, 1, object_id);
- if (sqlerr != SQLITE_OK) { goto loser; }
- do {
- sqlerr = sqlite3_step(stmt);
- if (sqlerr == SQLITE_BUSY) {
- PR_Sleep(SDB_BUSY_RETRY_TIME);
- }
- if (sqlerr == SQLITE_ROW) {
- for (i=0; i < count; i++) {
- int column = i;
+ do {
+ sqlerr = sqlite3_step(stmt);
+ if (sqlerr == SQLITE_BUSY) {
+ PR_Sleep(SDB_BUSY_RETRY_TIME);
+ }
+ if (sqlerr == SQLITE_ROW) {
int blobSize;
const char *blobData;
- blobSize = sqlite3_column_bytes(stmt, column);
- blobData = sqlite3_column_blob(stmt, column);
+ blobSize = sqlite3_column_bytes(stmt, 0);
+ blobData = sqlite3_column_blob(stmt, 0);
if (blobData == NULL) {
template[i].ulValueLen = -1;
error = CKR_ATTRIBUTE_TYPE_INVALID;
- continue;
+ break;
}
/* If the blob equals our explicit NULL value, then the
* attribute is a NULL. */
@@ -884,15 +882,18 @@
if (template[i].ulValueLen < blobSize) {
template[i].ulValueLen = -1;
error = CKR_BUFFER_TOO_SMALL;
- continue;
+ break;
}
PORT_Memcpy(template[i].pValue, blobData, blobSize);
}
template[i].ulValueLen = blobSize;
+ found = 1;
}
- found = 1;
- }
- } while (!sdb_done(sqlerr,&retry));
+ } while (!sdb_done(sqlerr,&retry));
+ sqlite3_reset(stmt);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ }
loser:
/* fix up the error if necessary */
@@ -902,9 +903,6 @@
error = CKR_OBJECT_HANDLE_INVALID;
}
}
- if (newStr) {
- sqlite3_free(newStr);
- }
if (stmt) {
sqlite3_reset(stmt);
« no previous file with comments | « nss/mozilla/security/nss/lib/softoken/sdb.h ('k') | nss/mozilla/security/nss/lib/softoken/softkver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698