Skip to content

Commit 9756440

Browse files
committed
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.
1 parent 6f54d04 commit 9756440

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

storage/innobase/log/log0crypt.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ log_crypt(byte* buf, ulint size, bool decrypt)
120120

121121
for (const byte* const end = buf + size; buf != end;
122122
buf += OS_FILE_LOG_BLOCK_SIZE) {
123-
byte dst[OS_FILE_LOG_BLOCK_SIZE - LOG_CRYPT_HDR_SIZE];
123+
uint32_t dst[(OS_FILE_LOG_BLOCK_SIZE - LOG_CRYPT_HDR_SIZE)
124+
/ sizeof(uint32_t)];
124125
const ulint log_block_no = log_block_get_hdr_no(buf);
125126

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

145145
int rc = encryption_crypt(
146-
buf + LOG_CRYPT_HDR_SIZE, sizeof dst, dst, &dst_len,
146+
buf + LOG_CRYPT_HDR_SIZE, sizeof dst,
147+
reinterpret_cast<byte*>(dst), &dst_len,
147148
const_cast<byte*>(info.crypt_key.bytes),
148149
sizeof info.crypt_key,
149150
reinterpret_cast<byte*>(aes_ctr_iv), sizeof aes_ctr_iv,

0 commit comments

Comments
 (0)