summaryrefslogtreecommitdiffstats
path: root/storage/maria/ma_crypt.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-01 18:15:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-01 18:15:00 +0000
commita2a2e32c02643a0cec111511220227703fda1cd5 (patch)
tree69cc2b631234c2a8e026b9cd4d72676c61c594df /storage/maria/ma_crypt.c
parentReleasing progress-linux version 1:10.11.8-1~progress7.99u1. (diff)
downloadmariadb-a2a2e32c02643a0cec111511220227703fda1cd5.tar.xz
mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.zip
Merging upstream version 1:11.4.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'storage/maria/ma_crypt.c')
-rw-r--r--storage/maria/ma_crypt.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/storage/maria/ma_crypt.c b/storage/maria/ma_crypt.c
index 1714fc6e..fe1ea09e 100644
--- a/storage/maria/ma_crypt.c
+++ b/storage/maria/ma_crypt.c
@@ -482,7 +482,7 @@ static int ma_encrypt(MARIA_SHARE *share, MARIA_CRYPT_DATA *crypt_data,
uint *key_version)
{
int rc;
- uint32 dstlen= 0; /* Must be set because of error message */
+ uint32 dstlen= size;
*key_version = encryption_key_get_latest_version(crypt_data->scheme.key_id);
if (unlikely(*key_version == ENCRYPTION_KEY_VERSION_INVALID))
@@ -509,6 +509,9 @@ static int ma_encrypt(MARIA_SHARE *share, MARIA_CRYPT_DATA *crypt_data,
DBUG_ASSERT(!my_assert_on_error || dstlen == size);
if (! (rc == MY_AES_OK && dstlen == size))
{
+ if (rc != MY_AES_OK)
+ dstlen= 0; /* reset dstlen if failed, to match expected message */
+
my_errno= HA_ERR_DECRYPTION_FAILED;
my_printf_error(HA_ERR_DECRYPTION_FAILED,
"failed to encrypt '%s' rc: %d dstlen: %u size: %u\n",
@@ -526,7 +529,7 @@ static int ma_decrypt(MARIA_SHARE *share, MARIA_CRYPT_DATA *crypt_data,
uint key_version)
{
int rc;
- uint32 dstlen= 0; /* Must be set because of error message */
+ uint32 dstlen= size;
rc= encryption_scheme_decrypt(src, size, dst, &dstlen,
&crypt_data->scheme, key_version,
@@ -536,6 +539,8 @@ static int ma_decrypt(MARIA_SHARE *share, MARIA_CRYPT_DATA *crypt_data,
DBUG_ASSERT(!my_assert_on_error || dstlen == size);
if (! (rc == MY_AES_OK && dstlen == size))
{
+ if (rc != MY_AES_OK)
+ dstlen= 0; /* reset dstlen if failed, to match expected message */
my_errno= HA_ERR_DECRYPTION_FAILED;
if (!share->silence_encryption_errors)
my_printf_error(HA_ERR_DECRYPTION_FAILED,