From a2a2e32c02643a0cec111511220227703fda1cd5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 1 Jul 2024 20:15:00 +0200 Subject: Merging upstream version 1:11.4.2. Signed-off-by: Daniel Baumann --- storage/maria/ma_crypt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'storage/maria/ma_crypt.c') 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, -- cgit v1.2.3