diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 4bae962..bfc13e7 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -564,19 +564,29 @@ buf_page_is_corrupted( checksum_field2 = mach_read_from_4( read_buf + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM); - /* declare empty pages non-corrupted */ + /* + Empty pages cannot be corrupted. However, the calculated checksum + will not be zero, so ensure that if the stored checksum is zero, + and the rest of the page is all zero, the page is considered not + corrupted. + */ if (checksum_field1 == 0 && checksum_field2 == 0 && mach_read_from_4(read_buf + FIL_PAGE_LSN) == 0) { - /* make sure that the page is really empty */ for (ulint i = 0; i < UNIV_PAGE_SIZE; i++) { if (read_buf[i] != 0) { - return(TRUE); + /* + The page has non-zero data, verify the + page checksum as usual. + */ + goto continue_checksum; } } return(FALSE); } +continue_checksum: + switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index ab7a197..7f2b03c 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -4905,19 +4905,29 @@ page_zip_verify_checksum( stored = static_cast<ib_uint32_t>(mach_read_from_4( static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - /* declare empty pages non-corrupted */ + /* + Empty pages cannot be corrupted. However, the calculated checksum + will not be zero, so ensure that if the stored checksum is zero, + and the rest of the page is all zero, the page is considered not + corrupted. + */ if (stored == 0) { - /* make sure that the page is really empty */ ulint i; for (i = 0; i < size; i++) { if (*((const char*) data + i) != 0) { - return(FALSE); + /* + The page has non-zero data, verify the + page checksum as usual. + */ + goto continue_checksum; } } return(TRUE); } +continue_checksum: + calc = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, static_cast<srv_checksum_algorithm_t>( srv_checksum_algorithm)));