mirror of
https://github.com/openssl/openssl.git
synced 2025-03-31 20:10:45 +08:00
enc: fix coverity 1451499, 1451501, 1451506, 1451507, 1351511, 1451514, 1451517, 1451523, 1451526m 1451528, 1451539, 1451441, 1451549, 1451568 & 1451572: improper use of negative value
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14638)
This commit is contained in:
parent
fe10fa7521
commit
1634b2df9f
@ -171,7 +171,7 @@ static int aria_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in, size_t len)
|
||||
{
|
||||
unsigned int num = EVP_CIPHER_CTX_num(ctx);
|
||||
EVP_ARIA_KEY *dat = EVP_C_DATA(EVP_ARIA_KEY,ctx);
|
||||
EVP_ARIA_KEY *dat = EVP_C_DATA(EVP_ARIA_KEY, ctx);
|
||||
|
||||
CRYPTO_ctr128_encrypt(in, out, len, &dat->ks, ctx->iv,
|
||||
EVP_CIPHER_CTX_buf_noconst(ctx), &num,
|
||||
|
@ -316,9 +316,13 @@ static int camellia_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
static int camellia_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in, size_t len)
|
||||
{
|
||||
unsigned int num = EVP_CIPHER_CTX_num(ctx);
|
||||
int snum = EVP_CIPHER_CTX_num(ctx);
|
||||
unsigned int num;
|
||||
EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
|
||||
|
||||
if (snum < 0)
|
||||
return 0;
|
||||
num = snum;
|
||||
if (dat->stream.ctr)
|
||||
CRYPTO_ctr128_encrypt_ctr32(in, out, len, &dat->ks, ctx->iv,
|
||||
EVP_CIPHER_CTX_buf_noconst(ctx), &num,
|
||||
|
@ -33,6 +33,11 @@ void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
unsigned long ti[2];
|
||||
unsigned char *iv, c, cc;
|
||||
|
||||
if (n < 0) {
|
||||
*num = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
iv = (unsigned char *)ivec;
|
||||
if (encrypt) {
|
||||
while (l--) {
|
||||
|
@ -35,6 +35,11 @@ void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
unsigned char *iv;
|
||||
int save = 0;
|
||||
|
||||
if (n < 0) {
|
||||
*num = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
iv = (unsigned char *)ivec;
|
||||
n2l(iv, v0);
|
||||
n2l(iv, v1);
|
||||
|
@ -30,6 +30,11 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
unsigned int n;
|
||||
size_t l = 0;
|
||||
|
||||
if (*num < 0) {
|
||||
/* There is no good way to signal an error return from here */
|
||||
*num = -1;
|
||||
return;
|
||||
}
|
||||
n = *num;
|
||||
|
||||
if (enc) {
|
||||
|
@ -155,7 +155,7 @@ void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
|
||||
{
|
||||
unsigned int n, ctr32;
|
||||
|
||||
n = *num;
|
||||
n = *num;
|
||||
|
||||
while (n && len) {
|
||||
*(out++) = *(in++) ^ ecount_buf[n];
|
||||
|
@ -29,6 +29,11 @@ void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
unsigned int n;
|
||||
size_t l = 0;
|
||||
|
||||
if (*num < 0) {
|
||||
/* There is no good way to signal an error return from here */
|
||||
*num = -1;
|
||||
return;
|
||||
}
|
||||
n = *num;
|
||||
|
||||
#if !defined(OPENSSL_SMALL_FOOTPRINT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user