diff options
author | Ben Laurie <ben@links.org> | 2014-07-05 14:54:02 +0100 |
---|---|---|
committer | Ben Laurie <ben@links.org> | 2014-07-05 15:00:53 +0100 |
commit | 6835f572a94f399db5cda484af3bbfe7c89de6b8 (patch) | |
tree | fb47a74053ebe61ffc89a5a63d7c60a73bf096e1 /crypto/evp/e_aes_cbc_hmac_sha256.c | |
parent | 7f6e9578648728478e84246fd3e64026b8b6a48e (diff) |
Reduce casting nastiness.
Diffstat (limited to 'crypto/evp/e_aes_cbc_hmac_sha256.c')
-rw-r--r-- | crypto/evp/e_aes_cbc_hmac_sha256.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crypto/evp/e_aes_cbc_hmac_sha256.c b/crypto/evp/e_aes_cbc_hmac_sha256.c index 31db13ef8d..447321266f 100644 --- a/crypto/evp/e_aes_cbc_hmac_sha256.c +++ b/crypto/evp/e_aes_cbc_hmac_sha256.c @@ -704,6 +704,7 @@ static int aesni_cbc_hmac_sha256_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) { EVP_AES_HMAC_SHA256 *key = data(ctx); + unsigned int u_arg = (unsigned int)arg; switch (type) { @@ -714,7 +715,10 @@ static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, vo memset (hmac_key,0,sizeof(hmac_key)); - if (arg > (int)sizeof(hmac_key)) { + if (arg < 0) + return -1; + + if (u_arg > sizeof(hmac_key)) { SHA256_Init(&key->head); SHA256_Update(&key->head,ptr,arg); SHA256_Final(hmac_key,&key->head); @@ -774,7 +778,10 @@ static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, vo unsigned int n4x=1, x4; unsigned int frag, last, packlen, inp_len; - if (arg<(int)sizeof(EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM)) return -1; + if (arg < 0) + return -1; + + if (u_arg < sizeof(EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM)) return -1; inp_len = param->inp[11]<<8|param->inp[12]; |