summaryrefslogtreecommitdiffstats
path: root/crypto/aes/aes_ige.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-02-20 19:17:53 -0500
committerRich Salz <rsalz@openssl.org>2017-02-20 19:17:53 -0500
commitb1498c98f3fb5b8a340acc9ce20b0fd5346294e5 (patch)
treef309540be655ed567f17a6e48aa0e51aee63c79f /crypto/aes/aes_ige.c
parentd913a0557f040e54120d028ced0a29767f7b12bb (diff)
Don't call memcpy if len is zero.
Prevent undefined behavior in CRYPTO_cbc128_encrypt: calling this function with the 'len' parameter being 0 would result in a memcpy where the source and destination parameters are the same, which is undefined behavior. Do same for AES_ige_encrypt. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2671)
Diffstat (limited to 'crypto/aes/aes_ige.c')
-rw-r--r--crypto/aes/aes_ige.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/aes/aes_ige.c b/crypto/aes/aes_ige.c
index 9125264ed9..75f796cf3b 100644
--- a/crypto/aes/aes_ige.c
+++ b/crypto/aes/aes_ige.c
@@ -41,6 +41,9 @@ void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
size_t n;
size_t len = length;
+ if (length == 0)
+ return;
+
OPENSSL_assert(in && out && key && ivec);
OPENSSL_assert((AES_ENCRYPT == enc) || (AES_DECRYPT == enc));
OPENSSL_assert((length % AES_BLOCK_SIZE) == 0);