From d87ffeb49133aa459e134f09924cd7b7b5013632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 7 Aug 2014 13:44:00 +0300 Subject: [PATCH] MDEV-6548: Incorrect compression on LZMA. Analysis: Provided incorrect parameter to output buffer size and incorrectly determined actual payload size after compression. --- storage/innobase/fil/fil0pagecompress.cc | 9 ++++++--- storage/xtradb/fil/fil0pagecompress.cc | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index a81a982db6c..8e7daf654fd 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -346,17 +346,20 @@ fil_compress_page( len, reinterpret_cast(out_buf + header_len), &out_pos, - (size_t)&write_size); + (size_t)write_size); - if (err != LZMA_OK || write_size > UNIV_PAGE_SIZE-header_len) { + if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { fprintf(stderr, "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", - space_id, fil_space_name(space), len, err, write_size); + space_id, fil_space_name(space), len, err, out_pos); srv_stats.pages_page_compression_error.inc(); *out_len = len; return (buf); } + + write_size = out_pos; + break; } #endif /* HAVE_LZMA */ diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index 854b094ea81..71815ca0318 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -345,16 +345,19 @@ fil_compress_page( len, reinterpret_cast(out_buf + header_len), &out_pos, - (size_t)&write_size); + (size_t)write_size); - if (err != LZMA_OK || write_size > UNIV_PAGE_SIZE-header_len) { + if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { fprintf(stderr, "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", - space_id, fil_space_name(space), len, err, write_size); + space_id, fil_space_name(space), len, err, out_pos); srv_stats.pages_page_compression_error.inc(); *out_len = len; return (buf); } + + write_size = out_pos; + break; } #endif /* HAVE_LZMA */