Skip to content

Commit

Permalink
Bug 1643557 - Change the type of the size argument to pk11_FindObject…
Browse files Browse the repository at this point in the history
…sByTemplate to be size_t, consistent with the type of some (small) numeric values passed to it after the previous revision. r=kjacobs

Depends on D78452

Differential Revision: https://phabricator.services.mozilla.com/D78453

--HG--
extra : moz-landing-system : lando
  • Loading branch information
jswalden committed Jun 5, 2020
1 parent 42c9547 commit 0234cbd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions lib/pk11wrap/pk11akey.c
Expand Up @@ -5,6 +5,8 @@
* This file contains functions to manage asymetric keys, (public and
* private keys).
*/
#include <stddef.h>

#include "seccomon.h"
#include "secmod.h"
#include "secmodi.h"
Expand Down Expand Up @@ -2548,7 +2550,7 @@ PK11_ListPublicKeysInSlot(PK11SlotInfo *slot, char *nickname)
CK_ATTRIBUTE *attrs;
CK_BBOOL ckTrue = CK_TRUE;
CK_OBJECT_CLASS keyclass = CKO_PUBLIC_KEY;
unsigned int tsize = 0;
size_t tsize = 0;
int objCount = 0;
CK_OBJECT_HANDLE *key_ids;
SECKEYPublicKeyList *keys;
Expand Down Expand Up @@ -2596,7 +2598,7 @@ PK11_ListPrivKeysInSlot(PK11SlotInfo *slot, char *nickname, void *wincx)
CK_ATTRIBUTE *attrs;
CK_BBOOL ckTrue = CK_TRUE;
CK_OBJECT_CLASS keyclass = CKO_PRIVATE_KEY;
unsigned int tsize = 0;
size_t tsize = 0;
int objCount = 0;
CK_OBJECT_HANDLE *key_ids;
SECKEYPrivateKeyList *keys;
Expand Down
4 changes: 3 additions & 1 deletion lib/pk11wrap/pk11cert.c
Expand Up @@ -5,6 +5,8 @@
* This file manages PKCS #11 instances of certificates.
*/

#include <stddef.h>

#include "secport.h"
#include "seccomon.h"
#include "secmod.h"
Expand Down Expand Up @@ -445,7 +447,7 @@ PK11_FindCertHandlesForKeyHandle(PK11SlotInfo *slot, CK_OBJECT_HANDLE keyHandle,
idTemplate[0],
{ CKA_CLASS, &searchClass, sizeof(searchClass) }
};
const int searchAttrCount = sizeof(searchTemplate) / sizeof(searchTemplate[0]);
const size_t searchAttrCount = sizeof(searchTemplate) / sizeof(searchTemplate[0]);
CK_OBJECT_HANDLE *ids = pk11_FindObjectsByTemplate(slot, searchTemplate, searchAttrCount, certHandleCountOut);

PORT_DestroyCheapArena(&arena);
Expand Down
7 changes: 4 additions & 3 deletions lib/pk11wrap/pk11obj.c
Expand Up @@ -5,6 +5,7 @@
* This file manages object type indepentent functions.
*/
#include <limits.h>
#include <stddef.h>

#include "seccomon.h"
#include "secmod.h"
Expand Down Expand Up @@ -1846,7 +1847,7 @@ pk11_FindObjectByTemplate(PK11SlotInfo *slot, CK_ATTRIBUTE *theTemplate, int tsi
*/
CK_OBJECT_HANDLE *
pk11_FindObjectsByTemplate(PK11SlotInfo *slot, CK_ATTRIBUTE *findTemplate,
int templCount, int *object_count)
size_t templCount, int *object_count)
{
CK_OBJECT_HANDLE *objID = NULL;
CK_ULONG returned_count = 0;
Expand Down Expand Up @@ -1941,7 +1942,7 @@ PK11_FindRawCertsWithSubject(PK11SlotInfo *slot, SECItem *derSubject,
{ CKA_CLASS, &cko_certificate, sizeof(cko_certificate) },
{ CKA_SUBJECT, derSubject->data, derSubject->len },
};
int templateCount = sizeof(subjectTemplate) / sizeof(subjectTemplate[0]);
const size_t templateCount = sizeof(subjectTemplate) / sizeof(subjectTemplate[0]);
int handleCount = 0;
CK_OBJECT_HANDLE *handles =
pk11_FindObjectsByTemplate(slot, subjectTemplate, templateCount,
Expand Down Expand Up @@ -2175,7 +2176,7 @@ PK11_FindObjectsFromNickname(char *nickname, PK11SlotInfo **slotptr,
{ CKA_LABEL, NULL, 0 },
{ CKA_CLASS, NULL, 0 },
};
int findCount = sizeof(findTemplate) / sizeof(findTemplate[0]);
const size_t findCount = sizeof(findTemplate) / sizeof(findTemplate[0]);
SECStatus rv;
PK11_SETATTRS(&findTemplate[1], CKA_CLASS, &objclass, sizeof(objclass));

Expand Down
5 changes: 4 additions & 1 deletion lib/pk11wrap/secmodi.h
Expand Up @@ -7,6 +7,9 @@
*/
#ifndef _SECMODI_H_
#define _SECMODI_H_ 1

#include <stddef.h>

#include "pkcs11.h"
#include "nssilock.h"
#include "secoidt.h"
Expand Down Expand Up @@ -92,7 +95,7 @@ void pk11_SignedToUnsigned(CK_ATTRIBUTE *attrib);
CK_OBJECT_HANDLE pk11_FindObjectByTemplate(PK11SlotInfo *slot,
CK_ATTRIBUTE *inTemplate, int tsize);
CK_OBJECT_HANDLE *pk11_FindObjectsByTemplate(PK11SlotInfo *slot,
CK_ATTRIBUTE *inTemplate, int tsize, int *objCount);
CK_ATTRIBUTE *inTemplate, size_t tsize, int *objCount);

#define PK11_GETTAB(x) ((CK_FUNCTION_LIST_3_0_PTR)((x)->functionList))
#define PK11_SETATTRS(x, id, v, l) \
Expand Down

0 comments on commit 0234cbd

Please sign in to comment.