Commit ed36fc35 authored by Marko Mäkelä's avatar Marko Mäkelä

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
parent 8ede9b3a
...@@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) ...@@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf)
case PAGE_ZLIB_ALGORITHM: case PAGE_ZLIB_ALGORITHM:
{ {
uLong len = srv_page_size; uLong len = srv_page_size;
if (Z_OK != uncompress(tmp_buf, &len, if (Z_OK == uncompress(tmp_buf, &len,
buf + header_len, buf + header_len,
uLong(actual_size)) uLong(actual_size))
&& len != srv_page_size) { && len == srv_page_size) {
return 0; break;
} }
} }
break; return 0;
#ifdef HAVE_LZ4 #ifdef HAVE_LZ4
case PAGE_LZ4_ALGORITHM: case PAGE_LZ4_ALGORITHM:
if (LZ4_decompress_safe(reinterpret_cast<const char*>(buf) if (LZ4_decompress_safe(reinterpret_cast<const char*>(buf)
......
...@@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) ...@@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf)
case PAGE_ZLIB_ALGORITHM: case PAGE_ZLIB_ALGORITHM:
{ {
uLong len = srv_page_size; uLong len = srv_page_size;
if (Z_OK != uncompress(tmp_buf, &len, if (Z_OK == uncompress(tmp_buf, &len,
buf + header_len, buf + header_len,
uLong(actual_size)) uLong(actual_size))
&& len != srv_page_size) { && len == srv_page_size) {
return 0; break;
} }
} }
break; return 0;
#ifdef HAVE_LZ4 #ifdef HAVE_LZ4
case PAGE_LZ4_ALGORITHM: case PAGE_LZ4_ALGORITHM:
if (LZ4_decompress_safe(reinterpret_cast<const char*>(buf) if (LZ4_decompress_safe(reinterpret_cast<const char*>(buf)
......
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