[openssl] master update
shane.lontis at oracle.com
shane.lontis at oracle.com
Mon Aug 24 01:24:37 UTC 2020
The branch master has been updated
via bc8c3e1cd8691e6c8e6fe208377ee0d0e408af73 (commit)
via 4bec3f6d5103c8244aa50d5d5a5b0374c91e7dfb (commit)
via 1f9ad4f953fb178137dbcd625da5ee2440b5449d (commit)
via 825ccf515528f289ae3dfe3b34d6252c4764069a (commit)
via 10ead93897ab48233d66cc40bfdc146d6c95c4a7 (commit)
via db1319b706b8f3b0d8d05d766da720812afc28c6 (commit)
via fa519461c96c8d5c4652cd0decc5dd62d7d13629 (commit)
via 51bba73e9361d19a0827e4459c01a7b3f6712415 (commit)
via fdf6118b1552bc723aeba726174b14ca07b5170a (commit)
via 26c5ea8f6168bba5c0879ac7b9bc62ed4e8d469c (commit)
via 75348bb29820a10c0afbe754fdd03ceacc91979e (commit)
via e499a64befa50bc2e7b9cb3173e8ac9b402fe1f9 (commit)
via ab7f4a3d2b86ef564081df7219301f7874c4d8af (commit)
via 61d61c5fd227903bb34562fc06531e91e9453f64 (commit)
via f2bfc53b02fd4cf328cf6200452b86adfdc15489 (commit)
via 90e0e0d8023fca71b019232ffc5804b8d07e2ff2 (commit)
via 3c1ccfea85e6dcb93aba5cfb166d7aa88bd0a587 (commit)
from 05ead000650b885deaf48b08509e8d14a5b7dd78 (commit)
- Log -----------------------------------------------------------------
commit bc8c3e1cd8691e6c8e6fe208377ee0d0e408af73
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 17:50:13 2020 +1000
Fix coverity CID #1452770 - Dereference before NULL check in CRYPTO_siv128_init()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 4bec3f6d5103c8244aa50d5d5a5b0374c91e7dfb
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 17:31:11 2020 +1000
Fix coverity CID #1452773 - Dereference before NULL check in EVP_DigestFinal_ex()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 1f9ad4f953fb178137dbcd625da5ee2440b5449d
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 17:18:31 2020 +1000
Fix coverity CID #1452775 & #1452772- Dereference before NULL check in evp_lib.c
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 825ccf515528f289ae3dfe3b34d6252c4764069a
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 17:09:18 2020 +1000
Fix coverity CID #1454638 - Dereference after NULL check in EVP_MD_CTX_gettable_params()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 10ead93897ab48233d66cc40bfdc146d6c95c4a7
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 17:01:07 2020 +1000
Fix coverity CID #1455335 - Dereference after NULL check in fromdata_init()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit db1319b706b8f3b0d8d05d766da720812afc28c6
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 16:50:10 2020 +1000
Fix coverity CID #1458641 - Dereference before NULL check when setting ctx->flag_allow_md in rsa.c
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit fa519461c96c8d5c4652cd0decc5dd62d7d13629
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 16:41:51 2020 +1000
Fix coverity CID #1458644 - Negative return passed to function taking size_t in ecdh_cms_set_shared_info()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 51bba73e9361d19a0827e4459c01a7b3f6712415
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 16:33:19 2020 +1000
Fix coverity CID #1458645 - Dereference before NULL check in rsa_digest_verify_final()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit fdf6118b1552bc723aeba726174b14ca07b5170a
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 16:28:00 2020 +1000
Fix coverity CID #1458647 - Use after free in clean_tbuf() which uses ctx->rsa
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 26c5ea8f6168bba5c0879ac7b9bc62ed4e8d469c
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 16:23:28 2020 +1000
Fix coverity CID #1458648 - Wrong sizeof() arg in rsa_freectx()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 75348bb29820a10c0afbe754fdd03ceacc91979e
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 15:56:17 2020 +1000
Fix coverity CID #1465525 - NULL pointer dereference in OSSL_DECODER_CTX_new_by_EVP_PKEY()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit e499a64befa50bc2e7b9cb3173e8ac9b402fe1f9
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 15:41:54 2020 +1000
Fix coverity CID #1465531 - Negative return passed to a function param using size_t in asn1_item_digest_with_libctx()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit ab7f4a3d2b86ef564081df7219301f7874c4d8af
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 15:36:49 2020 +1000
Fix coverity CID #1465790 - Dereference after NULL check in evp_test.c
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 61d61c5fd227903bb34562fc06531e91e9453f64
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 15:24:52 2020 +1000
Fix coverity CID #1465794 - Uninitialized pointer read in x942_encode_otherinfo()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit f2bfc53b02fd4cf328cf6200452b86adfdc15489
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 15:21:30 2020 +1000
Fix coverity CID #1465795 - Incorrect free deallocator used in SSL_add1_host()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 90e0e0d8023fca71b019232ffc5804b8d07e2ff2
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 15:17:17 2020 +1000
Fix coverity CID #1465797 - Negative loop bound in collect_deserializer
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
commit 3c1ccfea85e6dcb93aba5cfb166d7aa88bd0a587
Author: Shane Lontis <shane.lontis at oracle.com>
Date: Tue Aug 11 15:03:42 2020 +1000
Fix coverity CID #1465594 - Null dereference in EVP_PKEY_get0()
Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)
-----------------------------------------------------------------------
Summary of changes:
crypto/asn1/a_digest.c | 2 +-
crypto/ec/ec_ameth.c | 2 +-
crypto/encode_decode/decoder_pkey.c | 10 +++++++---
crypto/evp/digest.c | 19 ++++++++++++++-----
crypto/evp/evp_lib.c | 8 ++++----
crypto/evp/p_lib.c | 2 ++
crypto/evp/pmeth_gn.c | 3 ++-
crypto/modes/siv128.c | 22 ++++++++++++++--------
providers/implementations/kdfs/x942kdf.c | 2 +-
providers/implementations/signature/rsa.c | 16 ++++++++++------
ssl/ssl_lib.c | 2 +-
test/evp_test.c | 4 ++--
12 files changed, 59 insertions(+), 33 deletions(-)
diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c
index 3e7b418a19..9211d7a968 100644
--- a/crypto/asn1/a_digest.c
+++ b/crypto/asn1/a_digest.c
@@ -63,7 +63,7 @@ int asn1_item_digest_with_libctx(const ASN1_ITEM *it, const EVP_MD *md,
EVP_MD *fetched_md = (EVP_MD *)md;
i = ASN1_item_i2d(asn, &str, it);
- if (str == NULL)
+ if (i < 0 || str == NULL)
return 0;
if (EVP_MD_provider(md) == NULL) {
diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c
index 8840d57188..67705d6fe4 100644
--- a/crypto/ec/ec_ameth.c
+++ b/crypto/ec/ec_ameth.c
@@ -976,7 +976,7 @@ static int ecdh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
plen = CMS_SharedInfo_encode(&der, kekalg, ukm, keylen);
- if (!plen)
+ if (plen <= 0)
goto err;
if (EVP_PKEY_CTX_set0_ecdh_kdf_ukm(pctx, der, plen) <= 0)
diff --git a/crypto/encode_decode/decoder_pkey.c b/crypto/encode_decode/decoder_pkey.c
index 7f468c2476..7ab38f228f 100644
--- a/crypto/encode_decode/decoder_pkey.c
+++ b/crypto/encode_decode/decoder_pkey.c
@@ -289,6 +289,8 @@ static void collect_decoder(OSSL_DECODER *decoder, void *arg)
return;
data->error_occured = 1; /* Assume the worst */
+ if (data->names == NULL)
+ return;
end_i = sk_OPENSSL_CSTRING_num(data->names);
for (i = 0; i < end_i; i++) {
@@ -367,8 +369,10 @@ OSSL_DECODER_CTX *OSSL_DECODER_CTX_new_by_EVP_PKEY(EVP_PKEY **pkey,
data->process_data = NULL;
err:
- decoder_clean_EVP_PKEY_construct_arg(data->process_data);
- sk_OPENSSL_CSTRING_free(data->names);
- OPENSSL_free(data);
+ if (data != NULL) {
+ decoder_clean_EVP_PKEY_construct_arg(data->process_data);
+ sk_OPENSSL_CSTRING_free(data->names);
+ OPENSSL_free(data);
+ }
return ctx;
}
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 7caab8a5f7..f9ba59ca63 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -367,11 +367,18 @@ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
/* The caller can assume that this removes any secret data from the context */
int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *isize)
{
- int ret;
+ int ret, sz;
size_t size = 0;
- size_t mdsize = EVP_MD_size(ctx->digest);
+ size_t mdsize = 0;
- if (ctx->digest == NULL || ctx->digest->prov == NULL)
+ if (ctx->digest == NULL)
+ return 0;
+
+ sz = EVP_MD_size(ctx->digest);
+ if (sz < 0)
+ return 0;
+ mdsize = sz;
+ if (ctx->digest->prov == NULL)
goto legacy;
if (ctx->digest->dfinal == NULL) {
@@ -671,8 +678,10 @@ const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx)
{
EVP_PKEY_CTX *pctx;
- if (ctx != NULL
- && ctx->digest != NULL
+ if (ctx == NULL)
+ return NULL;
+
+ if (ctx->digest != NULL
&& ctx->digest->gettable_ctx_params != NULL)
return ctx->digest->gettable_ctx_params(
ossl_provider_ctx(EVP_MD_provider(ctx->digest)));
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
index c4d41518ef..676461a51b 100644
--- a/crypto/evp/evp_lib.c
+++ b/crypto/evp/evp_lib.c
@@ -638,14 +638,14 @@ const OSSL_PROVIDER *EVP_MD_provider(const EVP_MD *md)
int EVP_MD_block_size(const EVP_MD *md)
{
int ok;
- size_t v = md->block_size;
+ size_t v;
OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
if (md == NULL) {
EVPerr(EVP_F_EVP_MD_BLOCK_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
return -1;
}
-
+ v = md->block_size;
params[0] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_BLOCK_SIZE, &v);
ok = evp_do_md_getparams(md, params);
@@ -665,14 +665,14 @@ int EVP_MD_pkey_type(const EVP_MD *md)
int EVP_MD_size(const EVP_MD *md)
{
int ok;
- size_t v = md->md_size;
+ size_t v;
OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
if (md == NULL) {
EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
return -1;
}
-
+ v = md->md_size;
params[0] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_SIZE, &v);
ok = evp_do_md_getparams(md, params);
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index 7a79816788..503009dd93 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -720,6 +720,8 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
void *EVP_PKEY_get0(const EVP_PKEY *pkey)
{
+ if (pkey == NULL)
+ return NULL;
if (!evp_pkey_downgrade((EVP_PKEY *)pkey)) {
ERR_raise(ERR_LIB_EVP, EVP_R_INACCESSIBLE_KEY);
return NULL;
diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c
index 2f9346d998..3096828678 100644
--- a/crypto/evp/pmeth_gn.c
+++ b/crypto/evp/pmeth_gn.c
@@ -375,7 +375,8 @@ static int fromdata_init(EVP_PKEY_CTX *ctx, int operation)
return 1;
not_supported:
- ctx->operation = EVP_PKEY_OP_UNDEFINED;
+ if (ctx != NULL)
+ ctx->operation = EVP_PKEY_OP_UNDEFINED;
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
}
diff --git a/crypto/modes/siv128.c b/crypto/modes/siv128.c
index 27e29c3cc6..aa924efae7 100644
--- a/crypto/modes/siv128.c
+++ b/crypto/modes/siv128.c
@@ -168,13 +168,10 @@ int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
size_t out_len = SIV_LEN;
EVP_MAC_CTX *mac_ctx = NULL;
OSSL_PARAM params[3];
- const char *cbc_name = EVP_CIPHER_name(cbc);
+ const char *cbc_name;
- params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
- (char *)cbc_name, 0);
- params[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
- (void *)key, klen);
- params[2] = OSSL_PARAM_construct_end();
+ if (ctx == NULL)
+ return 0;
memset(&ctx->d, 0, sizeof(ctx->d));
EVP_CIPHER_CTX_free(ctx->cipher_ctx);
@@ -184,8 +181,17 @@ int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
ctx->cipher_ctx = NULL;
ctx->mac_ctx_init = NULL;
- if (key == NULL || cbc == NULL || ctr == NULL
- || (ctx->cipher_ctx = EVP_CIPHER_CTX_new()) == NULL
+ if (key == NULL || cbc == NULL || ctr == NULL)
+ return 0;
+
+ cbc_name = EVP_CIPHER_name(cbc);
+ params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
+ (char *)cbc_name, 0);
+ params[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
+ (void *)key, klen);
+ params[2] = OSSL_PARAM_construct_end();
+
+ if ((ctx->cipher_ctx = EVP_CIPHER_CTX_new()) == NULL
|| (ctx->mac =
EVP_MAC_fetch(libctx, OSSL_MAC_NAME_CMAC, propq)) == NULL
|| (ctx->mac_ctx_init = EVP_MAC_CTX_new(ctx->mac)) == NULL
diff --git a/providers/implementations/kdfs/x942kdf.c b/providers/implementations/kdfs/x942kdf.c
index 3ca87cddc2..d1a1ee443c 100644
--- a/providers/implementations/kdfs/x942kdf.c
+++ b/providers/implementations/kdfs/x942kdf.c
@@ -164,7 +164,7 @@ static int x942_encode_otherinfo(size_t keylen,
/* keylenbits must fit into 4 bytes */
if (keylen > 0xFFFFFF)
- goto err;
+ return 0;
keylen_bits = 8 * keylen;
/* Calculate the size of the buffer */
diff --git a/providers/implementations/signature/rsa.c b/providers/implementations/signature/rsa.c
index 05c47dfb65..ca7f6f23b9 100644
--- a/providers/implementations/signature/rsa.c
+++ b/providers/implementations/signature/rsa.c
@@ -725,7 +725,8 @@ static int rsa_digest_signverify_init(void *vprsactx, const char *mdname,
{
PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
- prsactx->flag_allow_md = 0;
+ if (prsactx != NULL)
+ prsactx->flag_allow_md = 0;
if (!rsa_signature_init(vprsactx, vrsa, operation)
|| !rsa_setup_md(prsactx, mdname, NULL)) /* TODO RL */
return 0;
@@ -775,10 +776,11 @@ static int rsa_digest_sign_final(void *vprsactx, unsigned char *sig,
unsigned char digest[EVP_MAX_MD_SIZE];
unsigned int dlen = 0;
+ if (prsactx == NULL)
+ return 0;
prsactx->flag_allow_md = 1;
- if (prsactx == NULL || prsactx->mdctx == NULL)
+ if (prsactx->mdctx == NULL)
return 0;
-
/*
* If sig is NULL then we're just finding out the sig size. Other fields
* are ignored. Defer to rsa_sign.
@@ -810,8 +812,10 @@ int rsa_digest_verify_final(void *vprsactx, const unsigned char *sig,
unsigned char digest[EVP_MAX_MD_SIZE];
unsigned int dlen = 0;
+ if (prsactx == NULL)
+ return 0;
prsactx->flag_allow_md = 1;
- if (prsactx == NULL || prsactx->mdctx == NULL)
+ if (prsactx->mdctx == NULL)
return 0;
/*
@@ -832,14 +836,14 @@ static void rsa_freectx(void *vprsactx)
if (prsactx == NULL)
return;
- RSA_free(prsactx->rsa);
EVP_MD_CTX_free(prsactx->mdctx);
EVP_MD_free(prsactx->md);
EVP_MD_free(prsactx->mgf1_md);
OPENSSL_free(prsactx->propq);
free_tbuf(prsactx);
+ RSA_free(prsactx->rsa);
- OPENSSL_clear_free(prsactx, sizeof(prsactx));
+ OPENSSL_clear_free(prsactx, sizeof(*prsactx));
}
static void *rsa_dupctx(void *vprsactx)
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index c72341547a..ad1cfb4f40 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -981,7 +981,7 @@ int SSL_add1_host(SSL *s, const char *hostname)
old_ip = X509_VERIFY_PARAM_get1_ip_asc(s->param);
if (old_ip)
{
- free(old_ip);
+ OPENSSL_free(old_ip);
/* There can be only one IP address */
return 0;
}
diff --git a/test/evp_test.c b/test/evp_test.c
index 958718b1ba..adcfea0038 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -1151,7 +1151,7 @@ static int mac_test_run_pkey(EVP_TEST *t)
OBJ_nid2sn(expected->type), expected->alg);
if (expected->type == EVP_PKEY_CMAC) {
- if (is_cipher_disabled(expected->alg)) {
+ if (expected->alg != NULL && is_cipher_disabled(expected->alg)) {
TEST_info("skipping, PKEY CMAC '%s' is disabled", expected->alg);
t->skip = 1;
t->err = NULL;
@@ -1174,7 +1174,7 @@ static int mac_test_run_pkey(EVP_TEST *t)
goto err;
}
- if (expected->type == EVP_PKEY_HMAC) {
+ if (expected->type == EVP_PKEY_HMAC && expected->alg != NULL) {
if (is_digest_disabled(expected->alg)) {
TEST_info("skipping, HMAC '%s' is disabled", expected->alg);
t->skip = 1;
More information about the openssl-commits
mailing list