Commit 8827eb83 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-8162 func_str crashes on SELECT AES_DECRYPT(AES_ENCRYPT(...)) on line 107

encrypting 0 byte string *is* possible
parent 8258a348
...@@ -71,8 +71,6 @@ static int block_crypt(CipherMode cipher, Dir dir, ...@@ -71,8 +71,6 @@ static int block_crypt(CipherMode cipher, Dir dir,
{ {
int tail= source_length % MY_AES_BLOCK_SIZE; int tail= source_length % MY_AES_BLOCK_SIZE;
DBUG_ASSERT(source_length);
if (likely(source_length >= MY_AES_BLOCK_SIZE || !no_padding)) if (likely(source_length >= MY_AES_BLOCK_SIZE || !no_padding))
{ {
#ifdef HAVE_YASSL #ifdef HAVE_YASSL
...@@ -139,7 +137,9 @@ static int block_crypt(CipherMode cipher, Dir dir, ...@@ -139,7 +137,9 @@ static int block_crypt(CipherMode cipher, Dir dir,
#endif #endif
} }
if (no_padding && tail) if (no_padding)
{
if (tail)
{ {
/* /*
Not much we can do, block ciphers cannot encrypt data that aren't Not much we can do, block ciphers cannot encrypt data that aren't
...@@ -161,6 +161,7 @@ static int block_crypt(CipherMode cipher, Dir dir, ...@@ -161,6 +161,7 @@ static int block_crypt(CipherMode cipher, Dir dir,
const uchar *m= mask; const uchar *m= mask;
while (s < e) while (s < e)
*d++ = *s++ ^ *m++; *d++ = *s++ ^ *m++;
}
*dest_length= source_length; *dest_length= source_length;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment