Skip to content

Commit 23993c0

Browse files
committed
MDEV-21993 asan failure in encryption.innochecksum
buf_is_zeroes(): stop assuming that argument buffer size is always a multiply of 4096. And thus stop reading past that buffer.
1 parent de9072c commit 23993c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,10 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum)
959959
bool buf_is_zeroes(span<const byte> buf)
960960
{
961961
static const byte zeroes[4 * 1024] = {0};
962-
for (size_t i = 0; i < buf.size(); i += sizeof(zeroes)) {
963-
if (memcmp(zeroes, buf.data() + i, sizeof(zeroes)) != 0)
962+
for (size_t i = 0; i < buf.size(); i += std::min(sizeof(zeroes),
963+
buf.size() - i)) {
964+
if (memcmp(zeroes, buf.data() + i, std::min(sizeof(zeroes),
965+
buf.size() - i)) != 0)
964966
return false;
965967
}
966968
return true;

0 commit comments

Comments
 (0)