summaryrefslogtreecommitdiff
path: root/lib/sqfs/comp/lzma.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-04 05:32:47 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-04 05:38:40 +0200
commit30597cc7c5d566f671c84c025de97cb1fc2d242e (patch)
tree985410632a31d952fb3430c001ed5e7780cf0e0b /lib/sqfs/comp/lzma.c
parent0f23f0396aede08a5d0c95d75b272f1b1787a365 (diff)
Strictly enfore min/max dictionary size in XZ & LZMA compressors
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/comp/lzma.c')
-rw-r--r--lib/sqfs/comp/lzma.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index 59871b1..b674af9 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -238,6 +238,12 @@ int lzma_compressor_create(const sqfs_compressor_config_t *cfg,
if (cfg->opt.lzma.dict_size == 0)
return SQFS_ERROR_UNSUPPORTED;
+ if (cfg->opt.lzma.dict_size < SQFS_LZMA_MIN_DICT_SIZE)
+ return SQFS_ERROR_UNSUPPORTED;
+
+ if (cfg->opt.lzma.dict_size > SQFS_LZMA_MAX_DICT_SIZE)
+ return SQFS_ERROR_UNSUPPORTED;
+
mask = cfg->opt.lzma.dict_size;
mask &= mask - 1;
@@ -262,9 +268,6 @@ int lzma_compressor_create(const sqfs_compressor_config_t *cfg,
lzma->lp = cfg->opt.lzma.lp;
lzma->pb = cfg->opt.lzma.pb;
- if (lzma->dict_size < SQFS_META_BLOCK_SIZE)
- lzma->dict_size = SQFS_META_BLOCK_SIZE;
-
base->get_configuration = lzma_get_configuration;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
lzma_uncomp_block : lzma_comp_block;