diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/journal/compress.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/journal/compress.c b/src/journal/compress.c index 49d694ac28..93ac92aaad 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -49,6 +49,13 @@ DEFINE_STRING_TABLE_LOOKUP(object_compressed, int); int compress_blob_xz(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size) { #ifdef HAVE_XZ + static const lzma_options_lzma opt = { + 1u << 20u, NULL, 0, LZMA_LC_DEFAULT, LZMA_LP_DEFAULT, + LZMA_PB_DEFAULT, LZMA_MODE_FAST, 128, LZMA_MF_HC3, 4}; + static const lzma_filter filters[2] = { + {LZMA_FILTER_LZMA2, (lzma_options_lzma*) &opt}, + {LZMA_VLI_UNKNOWN, NULL} + }; lzma_ret ret; size_t out_pos = 0; @@ -60,8 +67,11 @@ int compress_blob_xz(const void *src, uint64_t src_size, void *dst, uint64_t *ds /* Returns < 0 if we couldn't compress the data or the * compressed result is longer than the original */ - ret = lzma_easy_buffer_encode(LZMA_PRESET_DEFAULT, LZMA_CHECK_NONE, NULL, - src, src_size, dst, &out_pos, src_size - 1); + if (src_size < 80) + return -ENOBUFS; + + ret = lzma_stream_buffer_encode((lzma_filter*) filters, LZMA_CHECK_NONE, NULL, + src, src_size, dst, &out_pos, src_size - 1); if (ret != LZMA_OK) return -ENOBUFS; |