Skip to content

Commit

Permalink
Init secitem to avoid debug asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
lsh123 committed Dec 21, 2023
1 parent 8fc21b2 commit 8b7d5d4
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 33 deletions.
28 changes: 14 additions & 14 deletions src/nss/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ xmlSecNssAppAscii2UCS2Conv(PRBool toUnicode,
unsigned int *outBufLen,
PRBool swapBytes ATTRIBUTE_UNUSED)
{
SECItem it;
SECItem it = { siBuffer, NULL, 0 };

if (toUnicode == PR_FALSE) {
return (PR_FALSE);
Expand Down Expand Up @@ -289,7 +289,7 @@ xmlSecKeyPtr
xmlSecNssAppKeyLoadEx(const char *filename, xmlSecKeyDataType type ATTRIBUTE_UNUSED, xmlSecKeyDataFormat format,
const char *pwd, void* pwdCallback, void* pwdCallbackCtx
) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
xmlSecKeyPtr res;
int ret;

Expand Down Expand Up @@ -332,7 +332,7 @@ xmlSecNssAppKeyLoadEx(const char *filename, xmlSecKeyDataType type ATTRIBUTE_UNU
xmlSecKeyPtr
xmlSecNssAppKeyLoadMemory(const xmlSecByte* data, xmlSecSize dataSize, xmlSecKeyDataFormat format,
const char *pwd, void* pwdCallback, void* pwdCallbackCtx) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
xmlSecKeyPtr res;
int ret;

Expand Down Expand Up @@ -421,7 +421,7 @@ xmlSecNssAppDerKeyLoadSECItem(SECItem* secItem) {
SECKEYPublicKey *pubkey = NULL;
SECKEYPrivateKey *privkey = NULL;
CERTSubjectPublicKeyInfo *spki = NULL;
SECItem nickname;
SECItem nickname = { siBuffer, NULL, 0 };
PK11SlotInfo *slot = NULL;
SECStatus status;

Expand Down Expand Up @@ -590,7 +590,7 @@ xmlSecNssAppCheckCertMatchesKey(xmlSecKeyPtr key, CERTCertificate * cert) {
*/
int
xmlSecNssAppKeyCertLoad(xmlSecKeyPtr key, const char* filename, xmlSecKeyDataFormat format) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
int ret;

xmlSecAssert2(key != NULL, -1);
Expand Down Expand Up @@ -629,7 +629,7 @@ xmlSecNssAppKeyCertLoad(xmlSecKeyPtr key, const char* filename, xmlSecKeyDataFor
*/
int
xmlSecNssAppKeyCertLoadMemory(xmlSecKeyPtr key, const xmlSecByte* data, xmlSecSize dataSize, xmlSecKeyDataFormat format) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
int ret;

xmlSecAssert2(key != NULL, -1);
Expand Down Expand Up @@ -766,7 +766,7 @@ xmlSecKeyPtr
xmlSecNssAppPkcs12Load(const char *filename, const char *pwd,
void *pwdCallback ATTRIBUTE_UNUSED,
void* pwdCallbackCtx ATTRIBUTE_UNUSED) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
xmlSecKeyPtr res;
int ret;

Expand Down Expand Up @@ -809,7 +809,7 @@ xmlSecKeyPtr
xmlSecNssAppPkcs12LoadMemory(const xmlSecByte* data, xmlSecSize dataSize, const char *pwd,
void *pwdCallback ATTRIBUTE_UNUSED,
void* pwdCallbackCtx ATTRIBUTE_UNUSED) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
xmlSecKeyPtr res;
int ret;

Expand Down Expand Up @@ -856,8 +856,8 @@ xmlSecNssAppPkcs12LoadSECItem(SECItem* secItem, const char *pwd,
xmlSecKeyDataPtr x509Data = NULL;
int ret;
PK11SlotInfo *slot = NULL;
SECItem pwditem;
SECItem uc2_pwditem;
SECItem pwditem = { siBuffer, NULL, 0 };
SECItem uc2_pwditem = { siBuffer, NULL, 0 };
SECStatus rv;
SECKEYPrivateKey *privkey = NULL;
SECKEYPublicKey *pubkey = NULL;
Expand Down Expand Up @@ -1196,7 +1196,7 @@ int
xmlSecNssAppKeysMngrCertLoad(xmlSecKeysMngrPtr mngr, const char *filename,
xmlSecKeyDataFormat format,
xmlSecKeyDataType type) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
int ret;

xmlSecAssert2(mngr != NULL, -1);
Expand Down Expand Up @@ -1239,7 +1239,7 @@ int
xmlSecNssAppKeysMngrCertLoadMemory(xmlSecKeysMngrPtr mngr, const xmlSecByte* data,
xmlSecSize dataSize, xmlSecKeyDataFormat format,
xmlSecKeyDataType type) {
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
int ret;

xmlSecAssert2(mngr != NULL, -1);
Expand Down Expand Up @@ -1344,7 +1344,7 @@ int
xmlSecNssAppKeysMngrCrlLoad(xmlSecKeysMngrPtr mngr, const char *filename, xmlSecKeyDataFormat format) {
xmlSecKeyDataStorePtr x509Store;
CERTSignedCrl* crl;
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
int ret;

xmlSecAssert2(mngr != NULL, -1);
Expand Down Expand Up @@ -1412,7 +1412,7 @@ int
xmlSecNssAppKeysMngrCrlLoadMemory(xmlSecKeysMngrPtr mngr, const xmlSecByte* data, xmlSecSize dataSize, xmlSecKeyDataFormat format) {
xmlSecKeyDataStorePtr x509Store;
CERTSignedCrl* crl;
SECItem secItem;
SECItem secItem = { siBuffer, NULL, 0 };
int ret;

xmlSecAssert2(mngr != NULL, -1);
Expand Down
4 changes: 2 additions & 2 deletions src/nss/ciphers_cbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ xmlSecNssCbcCipherCtxInit(xmlSecNssCbcCipherCtxPtr ctx,
int encrypt, const xmlChar* cipherName,
xmlSecTransformCtxPtr transformCtx)
{
SECItem keyItem;
SECItem ivItem;
SECItem keyItem = { siBuffer, NULL, 0 };
SECItem ivItem = { siBuffer, NULL, 0 };
PK11SlotInfo* slot;
PK11SymKey* symKey;
int ivLen;
Expand Down
6 changes: 3 additions & 3 deletions src/nss/ciphers_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ xmlSecNssGcmCipherGetKey(xmlSecNssGcmCipherCtxPtr ctx, CK_ATTRIBUTE_TYPE operati
xmlSecBufferPtr keyBuf;
xmlSecSize keySize;
xmlSecByte* keyData;
SECItem key_item;
SECItem key_item = { siBuffer, NULL, 0 };
PK11SlotInfo *slot = NULL;
PK11SymKey *symKey = NULL;

Expand Down Expand Up @@ -251,7 +251,7 @@ xmlSecNssGcmCipherEncrypt(xmlSecNssGcmCipherCtxPtr ctx, xmlSecBufferPtr in, xmlS
xmlSecSize inSize, outSize;
xmlSecByte *plaintext, *iv, *outData;
CK_NSS_GCM_PARAMS gcm_params;
SECItem param;
SECItem param = { siBuffer, NULL, 0 };
PK11SymKey* symKey = NULL;
unsigned int outputlen = 0, maxoutputlen, inputlen;
SECStatus rv;
Expand Down Expand Up @@ -339,7 +339,7 @@ xmlSecNssGcmCipherDecrypt(xmlSecNssGcmCipherCtxPtr ctx, xmlSecBufferPtr in, xmlS
xmlSecSize inSize, outSize;
xmlSecByte *iv, *ciphertext, *outData;
CK_NSS_GCM_PARAMS gcm_params;
SECItem param;
SECItem param = { siBuffer, NULL, 0 };
PK11SymKey* symKey = NULL;
unsigned int outputlen = 0, maxoutputlen, inputlen;
SECStatus rv;
Expand Down
4 changes: 2 additions & 2 deletions src/nss/hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ xmlSecNssHmacSetKey(xmlSecTransformPtr transform, xmlSecKeyPtr key) {
xmlSecKeyDataPtr value;
xmlSecBufferPtr buffer;
xmlSecSize bufferSize;
SECItem keyItem;
SECItem ignore;
SECItem keyItem = { siBuffer, NULL, 0 };
SECItem ignore = { siBuffer, NULL, 0 };
PK11SlotInfo* slot;
PK11SymKey* symKey;

Expand Down
4 changes: 2 additions & 2 deletions src/nss/keytrans.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static int
xmlSecNssKeyTransportCtxFinal(xmlSecNssKeyTransportCtxPtr ctx, xmlSecBufferPtr in, xmlSecBufferPtr out,
int encrypt, xmlSecTransformCtxPtr transformCtx) {
PK11SymKey* symKey = NULL;
SECItem oriskv;
SECItem oriskv = { siBuffer, NULL, 0 };
xmlSecSize blockSize, materialSize, resultSize;
unsigned int resultLen;
xmlSecBufferPtr result;
Expand Down Expand Up @@ -471,7 +471,7 @@ xmlSecNssKeyTransportCtxFinal(xmlSecNssKeyTransportCtxPtr ctx, xmlSecBufferPtr i
XMLSEC_SAFE_CAST_SIZE_TO_UINT(materialSize, oriskv.len, goto done, NULL);

if(encrypt != 0) {
SECItem wrpskv;
SECItem wrpskv = { siBuffer, NULL, 0 };

/* Create template symmetric key from material if needed */
symKey = xmlSecNssKeyTransportLoadSymKeyUsingPublicKeySlot(ctx, &oriskv);
Expand Down
2 changes: 1 addition & 1 deletion src/nss/kw_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ xmlSecNSSKWAesEnsureKey(xmlSecNssKWAesCtxPtr ctx, int enc) {
xmlSecSize keySize;
CK_MECHANISM_TYPE cipherMech;
PK11SlotInfo* slot = NULL;
SECItem keyItem;
SECItem keyItem = { siBuffer, NULL, 0 };
int res = -1;

xmlSecAssert2(ctx != NULL, -1);
Expand Down
3 changes: 2 additions & 1 deletion src/nss/kw_des.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ xmlSecNssKWDes3Encrypt(const xmlSecByte *key, xmlSecSize keySize,
PK11SymKey* symKey = NULL;
SECItem* param = NULL;
PK11Context* pk11ctx = NULL;
SECItem keyItem, ivItem;
SECItem keyItem = { siBuffer, NULL, 0 };
SECItem ivItem = { siBuffer, NULL, 0 };
SECStatus status;
int inLen, outLen, maxOutLen;
int res = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/nss/pkikeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ xmlSecNssKeyDataEcRead(xmlSecKeyDataId id, xmlSecKeyValueEcPtr ecValue) {
CK_OBJECT_HANDLE handle;
SECKEYPublicKey *pubkey=NULL;
PRArenaPool *arena = NULL;
SECItem ecparams;
SECItem ecparams = { siBuffer, NULL, 0 };
SECOidData *oidData = NULL;
SECOidTag oidTag;
SECStatus rv;
Expand Down
6 changes: 3 additions & 3 deletions src/nss/signatures.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ xmlSecNssSignatureVerify(xmlSecTransformPtr transform,
xmlSecTransformCtxPtr transformCtx) {
xmlSecNssSignatureCtxPtr ctx;
SECStatus status;
SECItem signature;
SECItem signature = { siBuffer, NULL, 0 };

xmlSecAssert2(xmlSecNssSignatureCheckId(transform), -1);
xmlSecAssert2(transform->operation == xmlSecTransformOperationVerify, -1);
Expand All @@ -673,7 +673,7 @@ xmlSecNssSignatureVerify(xmlSecTransformPtr transform,

if(xmlSecNssSignatureAlgorithmEncoded(ctx->alg)) {
/* This creates a signature which is ASN1 encoded */
SECItem signatureDer;
SECItem signatureDer = { siBuffer, NULL, 0 };
SECStatus statusDer;

memset(&signatureDer, 0, sizeof(signatureDer));
Expand Down Expand Up @@ -758,7 +758,7 @@ xmlSecNssSignatureExecute(xmlSecTransformPtr transform, int last, xmlSecTransfor
xmlSecBufferPtr in, out;
xmlSecSize inSize, outSize;
SECStatus status;
SECItem signature;
SECItem signature = { siBuffer, NULL, 0 };
int ret;

xmlSecAssert2(xmlSecNssSignatureCheckId(transform), -1);
Expand Down
6 changes: 3 additions & 3 deletions src/nss/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ xmlSecNssKeyDataX509Write(xmlSecKeyDataPtr data, xmlSecKeyX509DataValuePtr x509V
}
}
if (XMLSEC_X509DATA_HAS_EMPTY_NODE(content, XMLSEC_X509DATA_SKI_NODE)) {
SECItem ski;
SECItem ski = { siBuffer, NULL, 0 };
SECStatus rv;

rv = CERT_FindSubjectKeyIDExtension(cert, &ski);
Expand Down Expand Up @@ -1168,7 +1168,7 @@ xmlSecNssX509SECItemWrite(SECItem* secItem, xmlSecBufferPtr buf) {
CERTCertificate*
xmlSecNssX509CertDerRead(CERTCertDBHandle *handle, xmlSecByte* buf, xmlSecSize size) {
CERTCertificate *cert;
SECItem derCert;
SECItem derCert = { siBuffer, NULL, 0 };

xmlSecAssert2(handle != NULL, NULL);
xmlSecAssert2(buf != NULL, NULL);
Expand All @@ -1190,7 +1190,7 @@ xmlSecNssX509CertDerRead(CERTCertDBHandle *handle, xmlSecByte* buf, xmlSecSize s
CERTSignedCrl*
xmlSecNssX509CrlDerRead(xmlSecByte* buf, xmlSecSize size, unsigned int flags) {
CERTSignedCrl *crl = NULL;
SECItem derCrl;
SECItem derCrl = { siBuffer, NULL, 0 };
PK11SlotInfo *slot = NULL;
PRInt32 importOptions = CRL_IMPORT_DEFAULT_OPTIONS;

Expand Down
2 changes: 1 addition & 1 deletion src/nss/x509vfy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ xmlSecNssX509FindCertCtxMatch(xmlSecNssX509FindCertCtxPtr ctx, CERTCertificate*

/* ski */
if( (ctx->skiItem.data != NULL) && (ctx->skiItem.len > 0)) {
SECItem tmpitem;
SECItem tmpitem = { siBuffer, NULL, 0 };

memset(&tmpitem, 0, sizeof(tmpitem));
status = CERT_FindSubjectKeyIDExtension(cert, &tmpitem);
Expand Down

0 comments on commit 8b7d5d4

Please sign in to comment.