diff options
author | rrelyea%redhat.com <devnull@localhost> | 2007-03-08 23:11:34 +0000 |
---|---|---|
committer | rrelyea%redhat.com <devnull@localhost> | 2007-03-08 23:11:34 +0000 |
commit | b948b5159d7f7e80125336ba9d320ad79d3b1270 (patch) | |
tree | a8b8bef845f426c17f3faf00786bf4c36367a1cd | |
parent | 3e0f38605de7693b97af14638d6011a0f5e1173e (diff) | |
download | nss-hg-b948b5159d7f7e80125336ba9d320ad79d3b1270.tar.gz |
C_FindObjectInit should return all objects when NULL is passed.
(pk11mode found this error). With this all.sh passes with the new db code.
-rw-r--r-- | security/nss/lib/softoken/sdb.c | 7 | ||||
-rw-r--r-- | security/nss/lib/softoken/sftkdb.c | 20 |
2 files changed, 21 insertions, 6 deletions
diff --git a/security/nss/lib/softoken/sdb.c b/security/nss/lib/softoken/sdb.c index b6da01c6e..8b783ecab 100644 --- a/security/nss/lib/softoken/sdb.c +++ b/security/nss/lib/softoken/sdb.c @@ -264,6 +264,7 @@ struct SDBFindStr { #define FIND_OBJECTS_CMD "SELECT ALL * FROM %s WHERE %s;" +#define FIND_OBJECTS_ALL_CMD "SELECT ALL * FROM %s;" CK_RV sdb_FindObjectsInit(SDB *sdb, const CK_ATTRIBUTE *template, int count, SDBFind **find) @@ -295,7 +296,11 @@ sdb_FindObjectsInit(SDB *sdb, const CK_ATTRIBUTE *template, int count, goto loser; } - newStr = sqlite3_mprintf(FIND_OBJECTS_CMD, sdb_p->table, findStr); + if (count == 0) { + newStr = sqlite3_mprintf(FIND_OBJECTS_ALL_CMD, sdb_p->table); + } else { + newStr = sqlite3_mprintf(FIND_OBJECTS_CMD, sdb_p->table, findStr); + } sqlite3_free(findStr); if (newStr == NULL) { error = CKR_HOST_MEMORY; diff --git a/security/nss/lib/softoken/sftkdb.c b/security/nss/lib/softoken/sftkdb.c index 65f958a15..e826059fb 100644 --- a/security/nss/lib/softoken/sftkdb.c +++ b/security/nss/lib/softoken/sftkdb.c @@ -422,17 +422,19 @@ CK_RV sftkdb_FindObjectsInit(SFTKDBHandle *handle, const CK_ATTRIBUTE *template, int count, SDBFind **find) { - unsigned char *data; - CK_ATTRIBUTE *ntemplate; + unsigned char *data = NULL; + CK_ATTRIBUTE *ntemplate = NULL; CK_RV crv; if (handle == NULL) { return CKR_OK; } - ntemplate = sftkdb_fixupTemplateIn(template, count, &data); - if (ntemplate == NULL) { - return CKR_HOST_MEMORY; + if (count != 0) { + ntemplate = sftkdb_fixupTemplateIn(template, count, &data); + if (ntemplate == NULL) { + return CKR_HOST_MEMORY; + } } crv = (*handle->db->sdb_FindObjectsInit)(handle->db, ntemplate, @@ -484,6 +486,10 @@ sftkdb_GetAttributeValue(SFTKDBHandle *handle, CK_OBJECT_HANDLE object_id, if (handle == NULL) { return CKR_GENERAL_ERROR; } + /* nothing to do */ + if (count == 0) { + return CKR_OK; + } ntemplate = sftkdb_fixupTemplateIn(template, count, &data); if (ntemplate == NULL) { return CKR_HOST_MEMORY; @@ -512,6 +518,10 @@ sftkdb_SetAttributeValue(SFTKDBHandle *handle, CK_OBJECT_HANDLE object_id, if (handle == NULL) { return CKR_TOKEN_WRITE_PROTECTED; } + /* nothing to do */ + if (count == 0) { + return CKR_OK; + } ntemplate = sftkdb_fixupTemplateIn(template, count, &data); if (ntemplate == NULL) { return CKR_HOST_MEMORY; |