]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: fix coverity 1473234 & 1473239: argument cannot be negative
authorPauli <ppzgs1@gmail.com>
Fri, 19 Mar 2021 04:49:42 +0000 (14:49 +1000)
committerPauli <pauli@openssl.org>
Wed, 7 Apr 2021 22:49:27 +0000 (08:49 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14620)

test/dhtest.c

index 189b5ae13ffe74d4a85ea0722933b12926b1cf14..b5ff81a319ac71047925498d780f7a0ea1a1319b 100644 (file)
@@ -666,12 +666,12 @@ static int rfc7919_test(void)
     DH_get0_key(b, &bpub_key, NULL);
 
     alen = DH_size(a);
-    if (!TEST_ptr(abuf = OPENSSL_malloc(alen))
+    if (!TEST_int_gt(alen, 0) || !TEST_ptr(abuf = OPENSSL_malloc(alen))
             || !TEST_true((aout = DH_compute_key(abuf, bpub_key, a)) != -1))
         goto err;
 
     blen = DH_size(b);
-    if (!TEST_ptr(bbuf = OPENSSL_malloc(blen))
+    if (!TEST_int_gt(blen, 0) || !TEST_ptr(bbuf = OPENSSL_malloc(blen))
             || !TEST_true((bout = DH_compute_key(bbuf, apub_key, b)) != -1))
         goto err;