From a03f81f4ead24c234dc26e388d86a352685f3948 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Fri, 19 Aug 2016 10:31:03 -0400 Subject: Fix NULL-return checks in 1.0.2 RT4386: Add sanity checks for BN_new() RT4384: Missing Sanity Checks for RSA_new_method() RT4384: Missing Sanity Check plus potential NULL pointer deref RT4382: Missing Sanity Check(s) for BUF_strdup() RT4380: Missing Sanity Checks for EVP_PKEY_new() RT4377: Prevent potential NULL pointer dereference RT4375: Missing sanity checks for OPENSSL_malloc() RT4374: Potential for NULL pointer dereferences RT4371: Missing Sanity Check for malloc() RT4370: Potential for NULL pointer dereferences Also expand tabs, make update, typo fix (rsalz) Minor tweak by Paul Dale. Some minor internal review feedback. Reviewed-by: Richard Levitte --- crypto/jpake/jpake.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crypto/jpake/jpake.c') diff --git a/crypto/jpake/jpake.c b/crypto/jpake/jpake.c index ebc0975575..1815735325 100644 --- a/crypto/jpake/jpake.c +++ b/crypto/jpake/jpake.c @@ -116,6 +116,8 @@ JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, const BIGNUM *secret) { JPAKE_CTX *ctx = OPENSSL_malloc(sizeof *ctx); + if (ctx == NULL) + return NULL; JPAKE_CTX_init(ctx, name, peer_name, p, g, q, secret); @@ -151,6 +153,8 @@ static void hashbn(SHA_CTX *sha, const BIGNUM *bn) size_t l = BN_num_bytes(bn); unsigned char *bin = OPENSSL_malloc(l); + if (bin == NULL) + return NULL; hashlength(sha, l); BN_bn2bin(bn, bin); SHA1_Update(sha, bin, l); -- cgit v1.2.3 From 71da19b050ba67c489b6c5f2543bf239c1947543 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Sun, 21 Aug 2016 12:50:05 -0400 Subject: Fix incorrect return argument. Reviewed-by: Dr. Stephen Henson --- crypto/jpake/jpake.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crypto/jpake/jpake.c') diff --git a/crypto/jpake/jpake.c b/crypto/jpake/jpake.c index 1815735325..2ba75f0172 100644 --- a/crypto/jpake/jpake.c +++ b/crypto/jpake/jpake.c @@ -154,7 +154,7 @@ static void hashbn(SHA_CTX *sha, const BIGNUM *bn) unsigned char *bin = OPENSSL_malloc(l); if (bin == NULL) - return NULL; + return; hashlength(sha, l); BN_bn2bin(bn, bin); SHA1_Update(sha, bin, l); -- cgit v1.2.3