Browse Source

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
pull/1482/head
Eugene Kosov 6 years ago
parent
commit
5e9e0b8e3b
  1. 10
      storage/innobase/buf/buf0buf.cc
  2. 2
      storage/innobase/include/page0size.h
  3. 10
      storage/innobase/page/page0zip.cc

10
storage/innobase/buf/buf0buf.cc

@ -958,14 +958,8 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum)
@return whether the buffer is all zeroes */ @return whether the buffer is all zeroes */
bool buf_is_zeroes(span<const byte> buf) 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. /** Check if a page is corrupt.

2
storage/innobase/include/page0size.h

@ -34,7 +34,7 @@ Created Nov 14, 2013 Vasil Dimov
/** A BLOB field reference full of zero, for use in assertions and /** A BLOB field reference full of zero, for use in assertions and
tests.Initially, BLOB field references are set to zero, in tests.Initially, BLOB field references are set to zero, in
dtuple_convert_big_rec(). */ 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 #define PAGE_SIZE_T_SIZE_BITS 17

10
storage/innobase/page/page0zip.cc

@ -34,12 +34,8 @@ using st_::span;
/** A BLOB field reference full of zero, for use in assertions and tests. /** A BLOB field reference full of zero, for use in assertions and tests.
Initially, BLOB field references are set to zero, in Initially, BLOB field references are set to zero, in
dtuple_convert_big_rec(). */ 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 #ifndef UNIV_INNOCHECKSUM
#include "page0page.h" #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. /** Assert that a BLOB pointer is filled with zero bytes.
@param b in: BLOB pointer */ @param b in: BLOB pointer */
#define ASSERT_ZERO_BLOB(b) \ #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 /* Enable some extra debugging output. This code can be enabled
independently of any UNIV_ debugging conditions. */ independently of any UNIV_ debugging conditions. */

Loading…
Cancel
Save