Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1347975 - coverity fixes for ec cleanup, r=ttaubert
Differential Revision: https://nss-review.dev.mozaws.net/D260

--HG--
extra : amend_source : c98ca3315496664dd81b6818df1bbdab542dc57b
  • Loading branch information
franziskuskiefer committed Mar 20, 2017
1 parent cc62cf3 commit be72de4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
6 changes: 4 additions & 2 deletions cmd/ecperf/ecperf.c
Expand Up @@ -482,7 +482,7 @@ ectest_curve_freebl(ECCurveName curve, int iterations, int numThreads,

rv = EC_NewKey(&ecParams, &ecPriv);
if (rv != SECSuccess) {
return SECFailure;
goto cleanup;
}
ecPub.ecParams = ecParams;
ecPub.publicValue = ecPriv->publicValue;
Expand Down Expand Up @@ -515,7 +515,9 @@ ectest_curve_freebl(ECCurveName curve, int iterations, int numThreads,
cleanup:
SECITEM_FreeItem(&ecEncodedParams, PR_FALSE);
PORT_FreeArena(arena, PR_FALSE);
PORT_FreeArena(ecPriv->ecParams.arena, PR_FALSE);
if (ecPriv) {
PORT_FreeArena(ecPriv->ecParams.arena, PR_FALSE);
}
return rv;
}

Expand Down
17 changes: 2 additions & 15 deletions lib/freebl/ecl/ecl.c
Expand Up @@ -267,31 +267,18 @@ ec_GetNamedCurveParams(const ECCurveName name)
ECGroup *
ECGroup_fromName(const ECCurveName name)
{
ECGroup *group = NULL;
const ECCurveBytes *params = NULL;
mp_err res = MP_OKAY;

/* This doesn't work with Curve25519 but it's not necessary to. */
PORT_Assert(name != ECCurve25519);

params = ec_GetNamedCurveParams(name);
if (params == NULL) {
res = MP_UNDEF;
goto CLEANUP;
return NULL;
}

/* construct actual group */
group = ecgroup_fromName(name, params);
if (group == NULL) {
res = MP_UNDEF;
}

CLEANUP:
if (group && res != MP_OKAY) {
ECGroup_free(group);
return NULL;
}
return group;
return ecgroup_fromName(name, params);
}

/* Validates an EC public key as described in Section 5.2.2 of X9.62. */
Expand Down

0 comments on commit be72de4

Please sign in to comment.