Skip to content

Commit d87ffeb

Browse files
author
Jan Lindström
committed
MDEV-6548: Incorrect compression on LZMA.
Analysis: Provided incorrect parameter to output buffer size and incorrectly determined actual payload size after compression.
1 parent 50777e2 commit d87ffeb

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

storage/innobase/fil/fil0pagecompress.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,20 @@ fil_compress_page(
346346
len,
347347
reinterpret_cast<uint8_t*>(out_buf + header_len),
348348
&out_pos,
349-
(size_t)&write_size);
349+
(size_t)write_size);
350350

351-
if (err != LZMA_OK || write_size > UNIV_PAGE_SIZE-header_len) {
351+
if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) {
352352
fprintf(stderr,
353353
"InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n",
354-
space_id, fil_space_name(space), len, err, write_size);
354+
space_id, fil_space_name(space), len, err, out_pos);
355355

356356
srv_stats.pages_page_compression_error.inc();
357357
*out_len = len;
358358
return (buf);
359359
}
360+
361+
write_size = out_pos;
362+
360363
break;
361364
}
362365
#endif /* HAVE_LZMA */

storage/xtradb/fil/fil0pagecompress.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,19 @@ fil_compress_page(
345345
len,
346346
reinterpret_cast<uint8_t*>(out_buf + header_len),
347347
&out_pos,
348-
(size_t)&write_size);
348+
(size_t)write_size);
349349

350-
if (err != LZMA_OK || write_size > UNIV_PAGE_SIZE-header_len) {
350+
if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) {
351351
fprintf(stderr,
352352
"InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n",
353-
space_id, fil_space_name(space), len, err, write_size);
353+
space_id, fil_space_name(space), len, err, out_pos);
354354
srv_stats.pages_page_compression_error.inc();
355355
*out_len = len;
356356
return (buf);
357357
}
358+
359+
write_size = out_pos;
360+
358361
break;
359362
}
360363
#endif /* HAVE_LZMA */

0 commit comments

Comments
 (0)