Skip to content

Commit

Permalink
Bug 1651834 - Fix various static analyzer warnings. r=rrelyea
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D87452

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Kevin Jacobs committed Aug 24, 2020
1 parent 3083761 commit 7dccc54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/pk11wrap/pk11cxt.c
Expand Up @@ -1159,6 +1159,9 @@ pk11_AEADSimulateOp(PK11Context *context, void *params, int paramslen,
* the tag. We'll copy the tag after the operation */
if (maxout < inlen + taglen) {
allocOut = PORT_Alloc(inlen + taglen);
if (allocOut == NULL) {
return SECFailure;
}
out = allocOut;
length = maxout = inlen + taglen;
}
Expand Down Expand Up @@ -1616,7 +1619,6 @@ pk11_Finalize(PK11Context *context)
} else {
buffer = PORT_Alloc(count);
if (buffer == NULL) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
return SECFailure;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/softoken/pkcs11c.c
Expand Up @@ -7030,7 +7030,7 @@ sftk_HKDF(CK_HKDF_PARAMS_PTR params, CK_SESSION_HANDLE hSession,
PORT_Memset(keyBlockData, 0, genLen);
PORT_Memset(hashbuf, 0, sizeof(hashbuf));
PORT_Free(keyBlockAlloc);
return CKR_OK;
return crv;
}

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/softoken/sdb.c
Expand Up @@ -2233,7 +2233,7 @@ sdb_init(char *dbname, char *table, sdbDataType type, int *inUpdate,
goto loser;
}
unsigned int schemaAttrsCapacity = known_attributes_size;
sdb_p->schemaAttrs = malloc(schemaAttrsCapacity * sizeof(CK_ATTRIBUTE));
sdb_p->schemaAttrs = malloc(schemaAttrsCapacity * sizeof(CK_ATTRIBUTE_TYPE));
if (!sdb_p->schemaAttrs) {
error = CKR_HOST_MEMORY;
goto loser;
Expand All @@ -2247,7 +2247,7 @@ sdb_init(char *dbname, char *table, sdbDataType type, int *inUpdate,
if (backedAttrs == schemaAttrsCapacity) {
schemaAttrsCapacity += known_attributes_size;
sdb_p->schemaAttrs = realloc(sdb_p->schemaAttrs,
schemaAttrsCapacity * sizeof(CK_ATTRIBUTE));
schemaAttrsCapacity * sizeof(CK_ATTRIBUTE_TYPE));
if (!sdb_p->schemaAttrs) {
error = CKR_HOST_MEMORY;
goto loser;
Expand Down
5 changes: 5 additions & 0 deletions lib/softoken/sftkpwd.c
Expand Up @@ -92,6 +92,11 @@ sftkdb_passwordToKey(SFTKDBHandle *keydb, SECItem *salt,
SHA1Context *cx = NULL;
SECStatus rv = SECFailure;

if (!pw) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
}

key->data = PORT_Alloc(SHA1_LENGTH);
if (key->data == NULL) {
goto loser;
Expand Down

0 comments on commit 7dccc54

Please sign in to comment.