diff options
author | Ryan Sleevi <ryan.sleevi@gmail.com> | 2015-01-09 14:49:18 -0800 |
---|---|---|
committer | Ryan Sleevi <ryan.sleevi@gmail.com> | 2015-01-09 14:49:18 -0800 |
commit | 41becb5ff46f11690d427f353f7504a51e74e210 (patch) | |
tree | 1f25e57a729740df8d0f35695b859d65b691e47b /lib/pk11wrap/pk11mech.c | |
parent | 06b7a50b274a7aed7d8296d489d026df7030d74f (diff) | |
download | nss-hg-41becb5ff46f11690d427f353f7504a51e74e210.tar.gz |
Bug 1094492 - Avoid corrupting memory if the allocator fails. r=wtc
Diffstat (limited to 'lib/pk11wrap/pk11mech.c')
-rw-r--r-- | lib/pk11wrap/pk11mech.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/pk11wrap/pk11mech.c b/lib/pk11wrap/pk11mech.c index e15a286b1..b7a7296b3 100644 --- a/lib/pk11wrap/pk11mech.c +++ b/lib/pk11wrap/pk11mech.c @@ -1378,12 +1378,13 @@ pk11_GenerateNewParamWithKeyLen(CK_MECHANISM_TYPE type, int keyLen) SECItem iv; SECStatus rv; - mech = (SECItem *) PORT_Alloc(sizeof(SECItem)); if (mech == NULL) return NULL; rv = SECSuccess; mech->type = siBuffer; + mech->data = NULL; + mech->len = 0; switch (type) { case CKM_RC4: case CKM_SEED_ECB: @@ -1396,8 +1397,6 @@ pk11_GenerateNewParamWithKeyLen(CK_MECHANISM_TYPE type, int keyLen) case CKM_CAST_ECB: case CKM_CAST3_ECB: case CKM_CAST5_ECB: - mech->data = NULL; - mech->len = 0; break; case CKM_RC2_ECB: rc2_ecb_params = (CK_RC2_PARAMS *)PORT_Alloc(sizeof(CK_RC2_PARAMS)); @@ -1445,8 +1444,6 @@ pk11_GenerateNewParamWithKeyLen(CK_MECHANISM_TYPE type, int keyLen) return PK11_ParamFromIV(type,&iv); default: if (pk11_lookup(type)->iv == 0) { - mech->data = NULL; - mech->len = 0; break; } case CKM_SEED_CBC: |