diff options
author | Pauli <paul.dale@oracle.com> | 2019-03-04 13:37:39 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2019-03-04 13:39:09 +1000 |
commit | 68ad17e87467e93eab87fc2fce0da53d6a7653cc (patch) | |
tree | bf12ccffee1072e46f52fe48e5d9fd29a05b70e3 /test/ecdsatest.c | |
parent | 38023b87f037f4b832c236dfce2a76272be08763 (diff) | |
download | openssl-68ad17e87467e93eab87fc2fce0da53d6a7653cc.zip openssl-68ad17e87467e93eab87fc2fce0da53d6a7653cc.tar.gz openssl-68ad17e87467e93eab87fc2fce0da53d6a7653cc.tar.bz2 |
Check for negative return for signature size.Addresses Coverity 1442933
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8392)
Diffstat (limited to 'test/ecdsatest.c')
-rw-r--r-- | test/ecdsatest.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/ecdsatest.c b/test/ecdsatest.c index 03327a2..761832f 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -205,6 +205,7 @@ static int test_builtin(int n) EVP_MD_CTX *mctx = NULL; size_t sig_len; int nid, ret = 0; + int temp; nid = curves[n].nid; @@ -231,9 +232,10 @@ static int test_builtin(int n) || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey_neg, eckey_neg))) goto err; - sig_len = ECDSA_size(eckey); + temp = ECDSA_size(eckey); - if (!TEST_ptr(sig = OPENSSL_malloc(sig_len)) + if (!TEST_int_ge(temp, 0) + || !TEST_ptr(sig = OPENSSL_malloc(sig_len = (size_t)temp)) /* create a signature */ || !TEST_true(EVP_DigestSignInit(mctx, NULL, NULL, NULL, pkey)) || !TEST_true(EVP_DigestSign(mctx, sig, &sig_len, tbs, sizeof(tbs))) |