diff options
author | Eugene Kosov <claprix@yandex.ru> | 2020-03-21 17:06:00 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2020-03-21 17:08:52 +0300 |
commit | 23993c0036bcccffb61bd7b13c4e0df9e94a6c7e (patch) | |
tree | 5ec609af53052cc669ec42117b16f0da5a002ca8 | |
parent | de9072ca19b84e0a33425248b7d4557c3e5ae89b (diff) | |
download | mariadb-git-23993c0036bcccffb61bd7b13c4e0df9e94a6c7e.tar.gz |
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.
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 8881ab5eb7a..cec39ab8e47 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -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; |