[openssl-commits] [openssl] master update
paul.dale at oracle.com
paul.dale at oracle.com
Thu Jul 13 21:31:34 UTC 2017
The branch master has been updated
via 9e206ce5f80172136b503ca23fbd8e53b78eb4b7 (commit)
from d72a00416a0691bfd4920008767221bb4082a2ed (commit)
- Log -----------------------------------------------------------------
commit 9e206ce5f80172136b503ca23fbd8e53b78eb4b7
Author: Pauli <paul.dale at oracle.com>
Date: Thu Jul 6 09:10:28 2017 +1000
Fix some issues raise by coverity in the tests.
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3846)
-----------------------------------------------------------------------
Summary of changes:
test/bntest.c | 6 +++---
test/danetest.c | 2 ++
test/evp_test.c | 14 +++++++++++---
test/exptest.c | 7 +++----
test/pbelutest.c | 20 +++++++-------------
5 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/test/bntest.c b/test/bntest.c
index 00bdf3f..59148b0 100644
--- a/test/bntest.c
+++ b/test/bntest.c
@@ -1367,9 +1367,9 @@ static int file_modexp(STANZA *s)
"0000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000001");
- BN_mod_exp(d, a, b, c, ctx);
- BN_mul(e, a, a, ctx);
- if (!TEST_BN_eq(d, e))
+ if (!TEST_true(BN_mod_exp(d, a, b, c, ctx))
+ || !TEST_true(BN_mul(e, a, a, ctx))
+ || !TEST_BN_eq(d, e))
goto err;
st = 1;
diff --git a/test/danetest.c b/test/danetest.c
index 89d6fb8..a0fd0ce 100644
--- a/test/danetest.c
+++ b/test/danetest.c
@@ -133,6 +133,8 @@ static STACK_OF(X509) *load_chain(BIO *fp, int nelem)
OPENSSL_free(name);
OPENSSL_free(header);
OPENSSL_free(data);
+ name = header = NULL;
+ data = NULL;
}
if (count == nelem) {
diff --git a/test/evp_test.c b/test/evp_test.c
index 36e29c4..700923b 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -1023,8 +1023,11 @@ static int pkey_test_init(EVP_TEST *t, const char *name,
return 0;
}
kdata->keyop = keyop;
- if (!TEST_ptr(kdata->ctx = EVP_PKEY_CTX_new(pkey, NULL)))
+ if (!TEST_ptr(kdata->ctx = EVP_PKEY_CTX_new(pkey, NULL))) {
+ EVP_PKEY_free(pkey);
+ OPENSSL_free(kdata);
return 0;
+ }
if (keyopinit(kdata->ctx) <= 0)
t->err = "KEYOP_INIT_ERROR";
t->data = kdata;
@@ -1624,10 +1627,15 @@ static int kdf_test_init(EVP_TEST *t, const char *name)
if (!TEST_ptr(kdata = OPENSSL_zalloc(sizeof(*kdata))))
return 0;
kdata->ctx = EVP_PKEY_CTX_new_id(OBJ_sn2nid(name), NULL);
- if (kdata->ctx == NULL)
+ if (kdata->ctx == NULL) {
+ OPENSSL_free(kdata);
return 0;
- if (EVP_PKEY_derive_init(kdata->ctx) <= 0)
+ }
+ if (EVP_PKEY_derive_init(kdata->ctx) <= 0) {
+ EVP_PKEY_CTX_free(kdata->ctx);
+ OPENSSL_free(kdata);
return 0;
+ }
t->data = kdata;
return 1;
}
diff --git a/test/exptest.c b/test/exptest.c
index e6f5213..9de922e 100644
--- a/test/exptest.c
+++ b/test/exptest.c
@@ -156,10 +156,9 @@ static int test_mod_exp(int round)
c = (c % BN_BITS) - BN_BITS2;
BN_rand(m, NUM_BITS + c, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD);
- BN_mod(a, a, m, ctx);
- BN_mod(b, b, m, ctx);
-
- if (!TEST_true(BN_mod_exp_mont(r_mont, a, b, m, ctx, NULL))
+ if (!TEST_true(BN_mod(a, a, m, ctx))
+ || !TEST_true(BN_mod(b, b, m, ctx))
+ || !TEST_true(BN_mod_exp_mont(r_mont, a, b, m, ctx, NULL))
|| !TEST_true(BN_mod_exp_recp(r_recp, a, b, m, ctx))
|| !TEST_true(BN_mod_exp_simple(r_simple, a, b, m, ctx))
|| !TEST_true(BN_mod_exp_mont_consttime(r_mont_const, a, b, m, ctx, NULL)))
diff --git a/test/pbelutest.c b/test/pbelutest.c
index c6ce586..84cb263 100644
--- a/test/pbelutest.c
+++ b/test/pbelutest.c
@@ -17,12 +17,12 @@
static int test_pbelu(void)
{
- int i, failed = 0, ok;
+ int i, failed = 0;
int pbe_type, pbe_nid, last_type = -1, last_nid = -1;
for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) {
if (!TEST_true(EVP_PBE_find(pbe_type, pbe_nid, NULL, NULL, 0))) {
- TEST_info("i=%d, pbe_type=%d, pbe_nid=%d", i, pbe_type, pbe_nid);
+ TEST_note("i=%d, pbe_type=%d, pbe_nid=%d", i, pbe_type, pbe_nid);
failed = 1;
break;
}
@@ -33,20 +33,14 @@ static int test_pbelu(void)
/* Error: print out whole table */
for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) {
- if (pbe_type > last_type)
- ok = 0;
- else if (pbe_type < last_type || pbe_nid < last_nid)
- ok = 1;
- else
- ok = 0;
- if (!ok)
- failed = 1;
- TEST_info("PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid,
- OBJ_nid2sn(pbe_nid), ok ? "ERROR" : "OK");
+ failed = pbe_type < last_type
+ || (pbe_type == last_type && pbe_nid < last_nid);
+ TEST_note("PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid,
+ OBJ_nid2sn(pbe_nid), failed ? "ERROR" : "OK");
last_type = pbe_type;
last_nid = pbe_nid;
}
- return failed ? 0 : 1;
+ return 0;
}
void register_tests(void)
More information about the openssl-commits
mailing list