Commit 5e9e0b8e authored by Eugene Kosov's avatar Eugene Kosov

MDEV-21993 asan failure in encryption.innochecksum

simplify fix

field_ref_zero: make bigger

buf_is_zeroes(): remove a loop and check in one go
parent 23993c00
......@@ -958,14 +958,8 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum)
@return whether the buffer is all zeroes */
bool buf_is_zeroes(span<const byte> buf)
{
static const byte zeroes[4 * 1024] = {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;
ut_ad(buf.size() <= sizeof field_ref_zero);
return memcmp(buf.data(), field_ref_zero, buf.size()) == 0;
}
/** Check if a page is corrupt.
......
......@@ -34,7 +34,7 @@ Created Nov 14, 2013 Vasil Dimov
/** A BLOB field reference full of zero, for use in assertions and
tests.Initially, BLOB field references are set to zero, in
dtuple_convert_big_rec(). */
extern const byte field_ref_zero[FIELD_REF_SIZE];
extern const byte field_ref_zero[UNIV_PAGE_SIZE_MAX];
#define PAGE_SIZE_T_SIZE_BITS 17
......
......@@ -34,12 +34,8 @@ using st_::span;
/** A BLOB field reference full of zero, for use in assertions and tests.
Initially, BLOB field references are set to zero, in
dtuple_convert_big_rec(). */
const byte field_ref_zero[FIELD_REF_SIZE] = {
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
};
MY_ALIGNED(UNIV_PAGE_SIZE_MAX)
const byte field_ref_zero[UNIV_PAGE_SIZE_MAX] = { 0, };
#ifndef UNIV_INNOCHECKSUM
#include "page0page.h"
......@@ -113,7 +109,7 @@ Compare at most sizeof(field_ref_zero) bytes.
/** Assert that a BLOB pointer is filled with zero bytes.
@param b in: BLOB pointer */
#define ASSERT_ZERO_BLOB(b) \
ut_ad(!memcmp(b, field_ref_zero, sizeof field_ref_zero))
ut_ad(!memcmp(b, field_ref_zero, FIELD_REF_SIZE))
/* Enable some extra debugging output. This code can be enabled
independently of any UNIV_ debugging conditions. */
......
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