Commit f341d944 authored by Jan Lindström's avatar Jan Lindström

MDEV-9549: Trying to decrypt a not encrypted page

Make sure that on decrypt we do not try to reference
NULL pointer and if page contains undefined
FIL_PAGE_FILE_FLUSH_LSN field on when page is not
the first page or page is not in system tablespace,
clear it.
parent 8c2fd553
......@@ -712,21 +712,37 @@ fil_space_decrypt(
ulint page_type = mach_read_from_2(src_frame+FIL_PAGE_TYPE);
uint key_version = mach_read_from_4(src_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
ulint offset = mach_read_from_4(src_frame + FIL_PAGE_OFFSET);
ulint space = mach_read_from_4(src_frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
ib_uint64_t lsn = mach_read_from_8(src_frame + FIL_PAGE_LSN);
*err = DB_SUCCESS;
if (key_version == ENCRYPTION_KEY_NOT_ENCRYPTED) {
return false;
}
ut_ad(crypt_data->encryption != FIL_SPACE_ENCRYPTION_OFF);
if (crypt_data == NULL) {
if (space != 0 && offset != 0 && key_version != 0) {
/* FIL_PAGE_FILE_FLUSH_LSN field i.e.
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
should be only defined for the
first page in a system tablespace
data file (ibdata*, not *.ibd), if not
clear it. */
#ifdef UNIV_DEBUG
ib_logf(IB_LOG_LEVEL_WARN,
"Page on space %lu offset %lu has key_version %u"
" when it shoud be undefined.",
space, offset, key_version);
#endif
mach_write_to_4(src_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 0);
}
return false;
}
/* read space & offset & lsn */
ulint space = mach_read_from_4(
src_frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
ulint offset = mach_read_from_4(
src_frame + FIL_PAGE_OFFSET);
ib_uint64_t lsn = mach_read_from_8(src_frame + FIL_PAGE_LSN);
ut_ad(crypt_data != NULL && crypt_data->encryption != FIL_SPACE_ENCRYPTION_OFF);
/* read space & lsn */
ulint header_len = FIL_PAGE_DATA;
if (page_compressed) {
......
......@@ -712,21 +712,37 @@ fil_space_decrypt(
ulint page_type = mach_read_from_2(src_frame+FIL_PAGE_TYPE);
uint key_version = mach_read_from_4(src_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
ulint offset = mach_read_from_4(src_frame + FIL_PAGE_OFFSET);
ulint space = mach_read_from_4(src_frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
ib_uint64_t lsn = mach_read_from_8(src_frame + FIL_PAGE_LSN);
*err = DB_SUCCESS;
if (key_version == ENCRYPTION_KEY_NOT_ENCRYPTED) {
return false;
}
ut_ad(crypt_data->encryption != FIL_SPACE_ENCRYPTION_OFF);
if (crypt_data == NULL) {
if (space != 0 && offset != 0 && key_version != 0) {
/* FIL_PAGE_FILE_FLUSH_LSN field i.e.
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
should be only defined for the
first page in a system tablespace
data file (ibdata*, not *.ibd), if not
clear it. */
#ifdef UNIV_DEBUG
ib_logf(IB_LOG_LEVEL_WARN,
"Page on space %lu offset %lu has key_version %u"
" when it shoud be undefined.",
space, offset, key_version);
#endif
mach_write_to_4(src_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 0);
}
return false;
}
/* read space & offset & lsn */
ulint space = mach_read_from_4(
src_frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
ulint offset = mach_read_from_4(
src_frame + FIL_PAGE_OFFSET);
ib_uint64_t lsn = mach_read_from_8(src_frame + FIL_PAGE_LSN);
ut_ad(crypt_data != NULL && crypt_data->encryption != FIL_SPACE_ENCRYPTION_OFF);
/* read space & lsn */
ulint header_len = FIL_PAGE_DATA;
if (page_compressed) {
......
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