Bug 469619: Coverity errors reported in libSMIME

Patch contributed by Shailendra Jain <shailen.n.jain@gmail.com>, r=nelson


git-svn-id: svn://10.0.0.236/trunk@259978 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nelson%bolyard.com 2010-03-15 07:25:15 +00:00
parent 166e017230
commit 2e8e9e524a
2 changed files with 11 additions and 7 deletions

View File

@ -40,7 +40,7 @@
* encoding/creation side *and* the decoding/decryption side. Anything
* else should be static routines in the appropriate file.
*
* $Id: p7local.c,v 1.13 2008-05-30 03:39:46 nelson%bolyard.com Exp $
* $Id: p7local.c,v 1.14 2010-03-15 07:25:14 nelson%bolyard.com Exp $
*/
#include "p7local.h"
@ -104,8 +104,8 @@ sec_PKCS7CreateDecryptObject (PK11SymKey *key, SECAlgorithmID *algid)
SECOidTag algtag;
void *ciphercx;
CK_MECHANISM_TYPE cryptoMechType;
SECItem *param;
PK11SlotInfo *slot;
SECItem *param = NULL;
result = (struct sec_pkcs7_cipher_object*)
PORT_ZAlloc (sizeof(struct sec_pkcs7_cipher_object));
@ -127,6 +127,7 @@ sec_PKCS7CreateDecryptObject (PK11SymKey *key, SECAlgorithmID *algid)
cryptoMechType = PK11_GetPBECryptoMechanism(algid, &param, pwitem);
if (cryptoMechType == CKM_INVALID_MECHANISM) {
PORT_Free(result);
SECITEM_FreeItem(param,PR_TRUE);
return NULL;
}
} else {
@ -178,11 +179,11 @@ sec_PKCS7CreateEncryptObject (PRArenaPool *poolp, PK11SymKey *key,
{
sec_PKCS7CipherObject *result;
void *ciphercx;
SECItem *param;
SECStatus rv;
CK_MECHANISM_TYPE cryptoMechType;
PRBool needToEncodeAlgid = PR_FALSE;
PK11SlotInfo *slot;
SECItem *param = NULL;
PRBool needToEncodeAlgid = PR_FALSE;
result = (struct sec_pkcs7_cipher_object*)
PORT_ZAlloc (sizeof(struct sec_pkcs7_cipher_object));
@ -202,6 +203,7 @@ sec_PKCS7CreateEncryptObject (PRArenaPool *poolp, PK11SymKey *key,
cryptoMechType = PK11_GetPBECryptoMechanism(algid, &param, pwitem);
if (cryptoMechType == CKM_INVALID_MECHANISM) {
PORT_Free(result);
SECITEM_FreeItem(param,PR_TRUE);
return NULL;
}
} else {

View File

@ -37,7 +37,7 @@
/*
* Encryption/decryption routines for CMS implementation, none of which are exported.
*
* $Id: cmscipher.c,v 1.12 2008-02-03 06:08:49 nelson%bolyard.com Exp $
* $Id: cmscipher.c,v 1.13 2010-03-15 07:25:15 nelson%bolyard.com Exp $
*/
#include "cmslocal.h"
@ -85,9 +85,9 @@ NSS_CMSCipherContext_StartDecrypt(PK11SymKey *key, SECAlgorithmID *algid)
NSSCMSCipherContext *cc;
void *ciphercx;
CK_MECHANISM_TYPE cryptoMechType;
SECItem *param;
PK11SlotInfo *slot;
SECOidTag algtag;
SECItem *param = NULL;
algtag = SECOID_GetAlgorithmTag(algid);
@ -101,6 +101,7 @@ NSS_CMSCipherContext_StartDecrypt(PK11SymKey *key, SECAlgorithmID *algid)
cryptoMechType = PK11_GetPBECryptoMechanism(algid, &param, pwitem);
if (cryptoMechType == CKM_INVALID_MECHANISM) {
SECITEM_FreeItem(param,PR_TRUE);
return NULL;
}
@ -154,10 +155,10 @@ NSS_CMSCipherContext_StartEncrypt(PRArenaPool *poolp, PK11SymKey *key, SECAlgori
{
NSSCMSCipherContext *cc;
void *ciphercx;
SECItem *param;
SECStatus rv;
CK_MECHANISM_TYPE cryptoMechType;
PK11SlotInfo *slot;
SECItem *param = NULL;
PRBool needToEncodeAlgid = PR_FALSE;
SECOidTag algtag = SECOID_GetAlgorithmTag(algid);
@ -171,6 +172,7 @@ NSS_CMSCipherContext_StartEncrypt(PRArenaPool *poolp, PK11SymKey *key, SECAlgori
cryptoMechType = PK11_GetPBECryptoMechanism(algid, &param, pwitem);
if (cryptoMechType == CKM_INVALID_MECHANISM) {
SECITEM_FreeItem(param,PR_TRUE);
return NULL;
}
} else {