]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
fix coverity 1485660 improper use of negative value
authorPauli <pauli@openssl.org>
Sun, 6 Jun 2021 23:23:41 +0000 (09:23 +1000)
committerPauli <pauli@openssl.org>
Tue, 8 Jun 2021 09:32:17 +0000 (19:32 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15635)

engines/e_padlock.c

index a22fc476e6fca940d59d4821fc63a4815b31be44..5662bf5b50b5d89249c5ba2fb81b8b0fc6451125 100644 (file)
@@ -457,7 +457,12 @@ padlock_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg,
                    const unsigned char *in_arg, size_t nbytes)
 {
     struct padlock_cipher_data *cdata = ALIGNED_CIPHER_DATA(ctx);
-    unsigned int num = EVP_CIPHER_CTX_get_num(ctx);
+    int n = EVP_CIPHER_CTX_get_num(ctx);
+    unsigned int num;
+
+    if (n < 0)
+        return 0;
+    num = (unsigned int)n;
 
     CRYPTO_ctr128_encrypt_ctr32(in_arg, out_arg, nbytes,
                                 cdata, EVP_CIPHER_CTX_iv_noconst(ctx),