From ed36fc353f374892c225d191f5525f439031d939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 20 Dec 2018 13:33:09 +0200 Subject: [PATCH] MDEV-18025: Detect corrupted innodb_page_compression=zlib pages In MDEV-13103, I made a mistake in the error handling of page_compressed=1 decryption when the default innodb_compression_algorithm=zlib is used. Due to this mistake, with certain versions of zlib, MariaDB would fail to detect a corrupted page. The problem was uncovered by the following tests: mariabackup.unencrypted_page_compressed mariabackup.encrypted_page_compressed --- storage/innobase/fil/fil0pagecompress.cc | 8 ++++---- storage/xtradb/fil/fil0pagecompress.cc | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index 25cd8e28a91..101f8fb0f31 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) case PAGE_ZLIB_ALGORITHM: { uLong len = srv_page_size; - if (Z_OK != uncompress(tmp_buf, &len, + if (Z_OK == uncompress(tmp_buf, &len, buf + header_len, uLong(actual_size)) - && len != srv_page_size) { - return 0; + && len == srv_page_size) { + break; } } - break; + return 0; #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: if (LZ4_decompress_safe(reinterpret_cast(buf) diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index 25cd8e28a91..101f8fb0f31 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) case PAGE_ZLIB_ALGORITHM: { uLong len = srv_page_size; - if (Z_OK != uncompress(tmp_buf, &len, + if (Z_OK == uncompress(tmp_buf, &len, buf + header_len, uLong(actual_size)) - && len != srv_page_size) { - return 0; + && len == srv_page_size) { + break; } } - break; + return 0; #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: if (LZ4_decompress_safe(reinterpret_cast(buf)