Skip to content
Permalink
Browse files
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.
  • Loading branch information
dr-m committed May 19, 2017
1 parent 6f54d04 commit 9756440
Showing 1 changed file with 5 additions and 4 deletions.
@@ -120,7 +120,8 @@ log_crypt(byte* buf, ulint size, bool decrypt)

for (const byte* const end = buf + size; buf != end;
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);

/* The log block number is not encrypted. */
@@ -130,8 +131,7 @@ log_crypt(byte* buf, ulint size, bool decrypt)
#else
~(LOG_BLOCK_FLUSH_BIT_MASK >> 24)
#endif
& (*reinterpret_cast<uint32_t*>(dst)
= *reinterpret_cast<const uint32_t*>(
& (*dst = *reinterpret_cast<const uint32_t*>(
buf + LOG_BLOCK_HDR_NO));
#if LOG_BLOCK_HDR_NO + 4 != LOG_CRYPT_HDR_SIZE
# error "LOG_BLOCK_HDR_NO has been moved; redo log format affected!"
@@ -143,7 +143,8 @@ log_crypt(byte* buf, ulint size, bool decrypt)
log_block_no));

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),
sizeof info.crypt_key,
reinterpret_cast<byte*>(aes_ctr_iv), sizeof aes_ctr_iv,

0 comments on commit 9756440

Please sign in to comment.