X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fjpake%2Fjpake.c;h=abbcb89a2aed9f1fdbbecf0918e22fcedec815f9;hp=eb6654d44fe683066b4f9e49735f2d7a9b4034c7;hb=6a78ae2821e89a8838714496524fd39d9d21fb1b;hpb=0f113f3ee4d629ef9a4a30911b22b224772085e5 diff --git a/crypto/jpake/jpake.c b/crypto/jpake/jpake.c index eb6654d44f..abbcb89a2a 100644 --- a/crypto/jpake/jpake.c +++ b/crypto/jpake/jpake.c @@ -107,14 +107,14 @@ static void JPAKE_CTX_release(JPAKE_CTX *ctx) OPENSSL_free(ctx->p.peer_name); OPENSSL_free(ctx->p.name); - memset(ctx, '\0', sizeof *ctx); + memset(ctx, 0, sizeof(*ctx)); } JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, const BIGNUM *secret) { - JPAKE_CTX *ctx = OPENSSL_malloc(sizeof *ctx); + JPAKE_CTX *ctx = OPENSSL_malloc(sizeof(*ctx)); if (ctx == NULL) return NULL; @@ -125,6 +125,8 @@ JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, void JPAKE_CTX_free(JPAKE_CTX *ctx) { + if (!ctx) + return; JPAKE_CTX_release(ctx); OPENSSL_free(ctx); } @@ -199,6 +201,9 @@ static int generate_zkp(JPAKE_STEP_PART *p, const BIGNUM *x, BIGNUM *h = BN_new(); BIGNUM *t = BN_new(); + if (r == NULL || h == NULL || t == NULL) + goto end; + /*- * r in [0,q) * XXX: Java chooses r in [0, 2^160) - i.e. distribution not uniform @@ -233,6 +238,9 @@ static int verify_zkp(const JPAKE_STEP_PART *p, const BIGNUM *zkpg, BIGNUM *t3 = BN_new(); int ret = 0; + if (h == NULL || t1 == NULL || t2 == NULL || t3 == NULL) + goto end; + if (!zkp_hash(h, zkpg, p, ctx->p.peer_name)) goto end;