diff options
author | Pauli <pauli@openssl.org> | 2021-06-29 08:18:30 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-30 13:55:09 +1000 |
commit | 98431c431366ec3445e92cf4c50a1d3ac80573a5 (patch) | |
tree | 189f5993b95cb24391dfe4d887163c9c8d17110b | |
parent | 159dacca4682a48ccc3625c64678b7eaf31681ef (diff) |
dh_test: fix coverity 1473239 Argument cannot be negative (NEGATIVE_RETURNS)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15943)
-rw-r--r-- | test/dhtest.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/test/dhtest.c b/test/dhtest.c index adbe3afd78..cb8d9a7de4 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -558,6 +558,7 @@ static int rfc5114_test(void) DH *dhB = NULL; unsigned char *Z1 = NULL; unsigned char *Z2 = NULL; + int szA, szB; const rfc5114_td *td = NULL; BIGNUM *priv_key = NULL, *pub_key = NULL; const BIGNUM *pub_key_tmp; @@ -580,12 +581,14 @@ static int rfc5114_test(void) goto bad_err; priv_key = pub_key = NULL; - if (!TEST_uint_eq(td->Z_len, (size_t)DH_size(dhA)) - || !TEST_uint_eq(td->Z_len, (size_t)DH_size(dhB))) + if (!TEST_int_gt(szA = DH_size(dhA), 0) + || !TEST_int_gt(szB = DH_size(dhB), 0) + || !TEST_size_t_eq(td->Z_len, (size_t)szA) + || !TEST_size_t_eq(td->Z_len, (size_t)szB)) goto err; - if (!TEST_ptr(Z1 = OPENSSL_malloc(DH_size(dhA))) - || !TEST_ptr(Z2 = OPENSSL_malloc(DH_size(dhB)))) + if (!TEST_ptr(Z1 = OPENSSL_malloc((size_t)szA)) + || !TEST_ptr(Z2 = OPENSSL_malloc((size_t)szB))) goto bad_err; /* * Work out shared secrets using both sides and compare with expected |