Commit 23993c00 authored by Eugene Kosov's avatar Eugene Kosov

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.
parent de9072ca
......@@ -959,8 +959,10 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum)
bool buf_is_zeroes(span<const byte> buf)
{
static const byte zeroes[4 * 1024] = {0};
for (size_t i = 0; i < buf.size(); i += sizeof(zeroes)) {
if (memcmp(zeroes, buf.data() + i, sizeof(zeroes)) != 0)
for (size_t i = 0; i < buf.size(); i += std::min(sizeof(zeroes),
buf.size() - i)) {
if (memcmp(zeroes, buf.data() + i, std::min(sizeof(zeroes),
buf.size() - i)) != 0)
return false;
}
return true;
......
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