summaryrefslogtreecommitdiff
path: root/lib/sqfs/comp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/comp')
-rw-r--r--lib/sqfs/comp/compressor.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/sqfs/comp/compressor.c b/lib/sqfs/comp/compressor.c
index bfc20b7..902ce92 100644
--- a/lib/sqfs/comp/compressor.c
+++ b/lib/sqfs/comp/compressor.c
@@ -87,12 +87,42 @@ bool sqfs_compressor_exists(E_SQFS_COMPRESSOR id)
sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg)
{
+ sqfs_u8 padd0[sizeof(cfg->opt)];
+ int ret;
+
if (cfg == NULL || cfg->id < SQFS_COMP_MIN || cfg->id > SQFS_COMP_MAX)
return NULL;
if (compressors[cfg->id] == NULL)
return NULL;
+ memset(padd0, 0, sizeof(padd0));
+
+ switch (cfg->id) {
+ case SQFS_COMP_XZ:
+ ret = memcmp(cfg->opt.xz.padd0, padd0,
+ sizeof(cfg->opt.xz.padd0));
+ break;
+ case SQFS_COMP_LZO:
+ ret = memcmp(cfg->opt.lzo.padd0, padd0,
+ sizeof(cfg->opt.lzo.padd0));
+ break;
+ case SQFS_COMP_ZSTD:
+ ret = memcmp(cfg->opt.zstd.padd0, padd0,
+ sizeof(cfg->opt.zstd.padd0));
+ break;
+ case SQFS_COMP_GZIP:
+ ret = memcmp(cfg->opt.gzip.padd0, padd0,
+ sizeof(cfg->opt.gzip.padd0));
+ break;
+ default:
+ ret = memcmp(cfg->opt.padd0, padd0, sizeof(cfg->opt.padd0));
+ break;
+ }
+
+ if (ret != 0)
+ return NULL;
+
return compressors[cfg->id](cfg);
}