Commit 9756440f authored by Marko Mäkelä's avatar Marko Mäkelä

Fix a compilation warning introduced by MDEV-11782

log_crypt(): Do not cast byte* to uint32_t*, because it may break
strict aliasing rules. Instead, cast in the opposite direction.
parent 6f54d04e
...@@ -120,7 +120,8 @@ log_crypt(byte* buf, ulint size, bool decrypt) ...@@ -120,7 +120,8 @@ log_crypt(byte* buf, ulint size, bool decrypt)
for (const byte* const end = buf + size; buf != end; for (const byte* const end = buf + size; buf != end;
buf += OS_FILE_LOG_BLOCK_SIZE) { buf += OS_FILE_LOG_BLOCK_SIZE) {
byte dst[OS_FILE_LOG_BLOCK_SIZE - LOG_CRYPT_HDR_SIZE]; uint32_t dst[(OS_FILE_LOG_BLOCK_SIZE - LOG_CRYPT_HDR_SIZE)
/ sizeof(uint32_t)];
const ulint log_block_no = log_block_get_hdr_no(buf); const ulint log_block_no = log_block_get_hdr_no(buf);
/* The log block number is not encrypted. */ /* The log block number is not encrypted. */
...@@ -130,8 +131,7 @@ log_crypt(byte* buf, ulint size, bool decrypt) ...@@ -130,8 +131,7 @@ log_crypt(byte* buf, ulint size, bool decrypt)
#else #else
~(LOG_BLOCK_FLUSH_BIT_MASK >> 24) ~(LOG_BLOCK_FLUSH_BIT_MASK >> 24)
#endif #endif
& (*reinterpret_cast<uint32_t*>(dst) & (*dst = *reinterpret_cast<const uint32_t*>(
= *reinterpret_cast<const uint32_t*>(
buf + LOG_BLOCK_HDR_NO)); buf + LOG_BLOCK_HDR_NO));
#if LOG_BLOCK_HDR_NO + 4 != LOG_CRYPT_HDR_SIZE #if LOG_BLOCK_HDR_NO + 4 != LOG_CRYPT_HDR_SIZE
# error "LOG_BLOCK_HDR_NO has been moved; redo log format affected!" # error "LOG_BLOCK_HDR_NO has been moved; redo log format affected!"
...@@ -143,7 +143,8 @@ log_crypt(byte* buf, ulint size, bool decrypt) ...@@ -143,7 +143,8 @@ log_crypt(byte* buf, ulint size, bool decrypt)
log_block_no)); log_block_no));
int rc = encryption_crypt( int rc = encryption_crypt(
buf + LOG_CRYPT_HDR_SIZE, sizeof dst, dst, &dst_len, buf + LOG_CRYPT_HDR_SIZE, sizeof dst,
reinterpret_cast<byte*>(dst), &dst_len,
const_cast<byte*>(info.crypt_key.bytes), const_cast<byte*>(info.crypt_key.bytes),
sizeof info.crypt_key, sizeof info.crypt_key,
reinterpret_cast<byte*>(aes_ctr_iv), sizeof aes_ctr_iv, reinterpret_cast<byte*>(aes_ctr_iv), sizeof aes_ctr_iv,
......
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