summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Walden <jwalden@mit.edu>2020-06-05 21:38:30 +0000
committerJeff Walden <jwalden@mit.edu>2020-06-05 21:38:30 +0000
commitbcca69bc0189f3d9084d509733c34206c81a52e1 (patch)
tree7bea286e397abc12b48be7ddfb7b94f43d0d64e6
parent7ee3a804dc3c1b5e875434d1c37264b7e7fdcd20 (diff)
downloadnss-hg-bcca69bc0189f3d9084d509733c34206c81a52e1.tar.gz
Bug 1643557 - Make pk11_FindObjectByTemplate accept a size_t count rather than a signed type to avoid internal signed-unsigned comparison warnings. r=kjacobs
Depends on D78454 Differential Revision: https://phabricator.services.mozilla.com/D78455
-rw-r--r--lib/pk11wrap/pk11cert.c14
-rw-r--r--lib/pk11wrap/pk11kea.c4
-rw-r--r--lib/pk11wrap/pk11merge.c2
-rw-r--r--lib/pk11wrap/pk11nobj.c4
-rw-r--r--lib/pk11wrap/pk11obj.c4
-rw-r--r--lib/pk11wrap/pk11skey.c2
-rw-r--r--lib/pk11wrap/secmodi.h2
7 files changed, 18 insertions, 14 deletions
diff --git a/lib/pk11wrap/pk11cert.c b/lib/pk11wrap/pk11cert.c
index a192c6951..8375e2bb4 100644
--- a/lib/pk11wrap/pk11cert.c
+++ b/lib/pk11wrap/pk11cert.c
@@ -1257,9 +1257,9 @@ PK11_ImportDERCert(PK11SlotInfo *slot, SECItem *derCert,
/*
* get a certificate handle, look at the cached handle first..
*/
-CK_OBJECT_HANDLE
+static CK_OBJECT_HANDLE
pk11_getcerthandle(PK11SlotInfo *slot, CERTCertificate *cert,
- CK_ATTRIBUTE *theTemplate, int tsize)
+ CK_ATTRIBUTE *theTemplate, size_t tsize)
{
CK_OBJECT_HANDLE certh;
@@ -1291,7 +1291,7 @@ PK11_FindPrivateKeyFromCert(PK11SlotInfo *slot, CERTCertificate *cert,
{ CKA_CLASS, NULL, 0 }
};
/* if you change the array, change the variable below as well */
- int tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
+ const size_t tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
CK_OBJECT_HANDLE certh;
CK_OBJECT_HANDLE keyh;
CK_ATTRIBUTE *attrs = theTemplate;
@@ -1461,7 +1461,7 @@ PK11_ImportDERCertForKey(SECItem *derCert, char *nickname, void *wincx)
static CK_OBJECT_HANDLE
pk11_FindCertObjectByTemplate(PK11SlotInfo **slotPtr,
- CK_ATTRIBUTE *searchTemplate, int count, void *wincx)
+ CK_ATTRIBUTE *searchTemplate, size_t count, void *wincx)
{
PK11SlotList *list;
PK11SlotListElement *le;
@@ -2043,7 +2043,7 @@ PK11_FindObjectForCert(CERTCertificate *cert, void *wincx, PK11SlotInfo **pSlot)
{ CKA_CLASS, NULL, 0 },
{ CKA_VALUE, NULL, 0 },
};
- int templateSize = sizeof(searchTemplate) / sizeof(searchTemplate[0]);
+ const size_t templateSize = sizeof(searchTemplate) / sizeof(searchTemplate[0]);
attr = searchTemplate;
PK11_SETATTRS(attr, CKA_CLASS, &certClass, sizeof(certClass));
@@ -2642,7 +2642,7 @@ PK11_FindCertInSlot(PK11SlotInfo *slot, CERTCertificate *cert, void *wincx)
{ CKA_CLASS, NULL, 0 }
};
/* if you change the array, change the variable below as well */
- int tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
+ const size_t tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
CK_ATTRIBUTE *attrs = theTemplate;
SECStatus rv;
@@ -2793,7 +2793,7 @@ PK11_GetLowLevelKeyIDForCert(PK11SlotInfo *slot,
{ CKA_CLASS, NULL, 0 }
};
/* if you change the array, change the variable below as well */
- int tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
+ const size_t tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
CK_OBJECT_HANDLE certHandle;
CK_ATTRIBUTE *attrs = theTemplate;
PK11SlotInfo *slotRef = NULL;
diff --git a/lib/pk11wrap/pk11kea.c b/lib/pk11wrap/pk11kea.c
index 1f228cfaf..249a301ad 100644
--- a/lib/pk11wrap/pk11kea.c
+++ b/lib/pk11wrap/pk11kea.c
@@ -6,6 +6,8 @@
* Interfaces.
*/
+#include <stddef.h>
+
#include "seccomon.h"
#include "secmod.h"
#include "nssilock.h"
@@ -29,7 +31,7 @@ pk11_FindRSAPubKey(PK11SlotInfo *slot)
CK_KEY_TYPE key_type = CKK_RSA;
CK_OBJECT_CLASS class_type = CKO_PUBLIC_KEY;
CK_ATTRIBUTE theTemplate[2];
- int template_count = sizeof(theTemplate) / sizeof(theTemplate[0]);
+ size_t template_count = sizeof(theTemplate) / sizeof(theTemplate[0]);
CK_ATTRIBUTE *attrs = theTemplate;
PK11_SETATTRS(attrs, CKA_CLASS, &class_type, sizeof(class_type));
diff --git a/lib/pk11wrap/pk11merge.c b/lib/pk11wrap/pk11merge.c
index c7b5b709d..d6d9da718 100644
--- a/lib/pk11wrap/pk11merge.c
+++ b/lib/pk11wrap/pk11merge.c
@@ -464,7 +464,7 @@ pk11_mergeSecretKey(PK11SlotInfo *targetSlot, PK11SlotInfo *sourceSlot,
{ CKA_ID, NULL, 0 },
{ CKA_CLASS, NULL, 0 }
};
- CK_ULONG symTemplateCount = sizeof(symTemplate) / sizeof(symTemplate[0]);
+ const CK_ULONG symTemplateCount = sizeof(symTemplate) / sizeof(symTemplate[0]);
CK_ATTRIBUTE symCopyTemplate[] = {
{ CKA_LABEL, NULL, 0 }
};
diff --git a/lib/pk11wrap/pk11nobj.c b/lib/pk11wrap/pk11nobj.c
index dcc1b7ae5..80bc009f7 100644
--- a/lib/pk11wrap/pk11nobj.c
+++ b/lib/pk11wrap/pk11nobj.c
@@ -6,6 +6,8 @@
* etc).
*/
+#include <stddef.h>
+
#include "secport.h"
#include "seccomon.h"
#include "secmod.h"
@@ -552,7 +554,7 @@ PK11_FindSMimeProfile(PK11SlotInfo **slot, char *emailAddr,
{ CKA_VALUE, NULL, 0 },
};
/* if you change the array, change the variable below as well */
- int tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
+ const size_t tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
CK_OBJECT_HANDLE smimeh = CK_INVALID_HANDLE;
CK_ATTRIBUTE *attrs = theTemplate;
CK_RV crv;
diff --git a/lib/pk11wrap/pk11obj.c b/lib/pk11wrap/pk11obj.c
index 8ca8e8a3d..4432b8e3a 100644
--- a/lib/pk11wrap/pk11obj.c
+++ b/lib/pk11wrap/pk11obj.c
@@ -1808,7 +1808,7 @@ PK11_ReadRawAttributes(PLArenaPool *arena, PK11ObjectType objType, void *objSpec
* return the object handle that matches the template
*/
CK_OBJECT_HANDLE
-pk11_FindObjectByTemplate(PK11SlotInfo *slot, CK_ATTRIBUTE *theTemplate, int tsize)
+pk11_FindObjectByTemplate(PK11SlotInfo *slot, CK_ATTRIBUTE *theTemplate, size_t tsize)
{
CK_OBJECT_HANDLE object;
CK_RV crv = CKR_SESSION_HANDLE_INVALID;
@@ -2022,7 +2022,7 @@ PK11_MatchItem(PK11SlotInfo *slot, CK_OBJECT_HANDLE searchID,
};
/* if you change the array, change the variable below as well */
CK_ATTRIBUTE *keyclass = &theTemplate[1];
- int tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
+ const size_t tsize = sizeof(theTemplate) / sizeof(theTemplate[0]);
/* if you change the array, change the variable below as well */
CK_OBJECT_HANDLE peerID;
PORTCheapArenaPool tmpArena;
diff --git a/lib/pk11wrap/pk11skey.c b/lib/pk11wrap/pk11skey.c
index 7d15b6159..996c03950 100644
--- a/lib/pk11wrap/pk11skey.c
+++ b/lib/pk11wrap/pk11skey.c
@@ -570,7 +570,7 @@ PK11_FindFixedKey(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, SECItem *keyID,
CK_ATTRIBUTE *attrs;
CK_BBOOL ckTrue = CK_TRUE;
CK_OBJECT_CLASS keyclass = CKO_SECRET_KEY;
- int tsize = 0;
+ size_t tsize = 0;
CK_OBJECT_HANDLE key_id;
attrs = findTemp;
diff --git a/lib/pk11wrap/secmodi.h b/lib/pk11wrap/secmodi.h
index 940f6900d..9f220d6bf 100644
--- a/lib/pk11wrap/secmodi.h
+++ b/lib/pk11wrap/secmodi.h
@@ -93,7 +93,7 @@ CK_RV pk11_notify(CK_SESSION_HANDLE session, CK_NOTIFICATION event,
CK_VOID_PTR pdata);
void pk11_SignedToUnsigned(CK_ATTRIBUTE *attrib);
CK_OBJECT_HANDLE pk11_FindObjectByTemplate(PK11SlotInfo *slot,
- CK_ATTRIBUTE *inTemplate, int tsize);
+ CK_ATTRIBUTE *inTemplate, size_t tsize);
CK_OBJECT_HANDLE *pk11_FindObjectsByTemplate(PK11SlotInfo *slot,
CK_ATTRIBUTE *inTemplate, size_t tsize, int *objCount);