aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/comp/compressor.c30
-rw-r--r--lib/sqfs/data_writer/common.c8
-rw-r--r--lib/sqfs/read_tree.c3
-rw-r--r--lib/sqfshelper/statistics.c1
4 files changed, 40 insertions, 2 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);
}
diff --git a/lib/sqfs/data_writer/common.c b/lib/sqfs/data_writer/common.c
index 059ef41..a19eb6d 100644
--- a/lib/sqfs/data_writer/common.c
+++ b/lib/sqfs/data_writer/common.c
@@ -157,9 +157,13 @@ int sqfs_data_writer_write_fragment_table(sqfs_data_writer_t *proc,
return 0;
}
-void sqfs_data_writer_set_hooks(sqfs_data_writer_t *proc, void *user_ptr,
- const sqfs_block_hooks_t *hooks)
+int sqfs_data_writer_set_hooks(sqfs_data_writer_t *proc, void *user_ptr,
+ const sqfs_block_hooks_t *hooks)
{
+ if (hooks->size != sizeof(*hooks))
+ return SQFS_ERROR_UNSUPPORTED;
+
proc->hooks = hooks;
proc->user_ptr = user_ptr;
+ return 0;
}
diff --git a/lib/sqfs/read_tree.c b/lib/sqfs/read_tree.c
index 46c7ec0..3a43769 100644
--- a/lib/sqfs/read_tree.c
+++ b/lib/sqfs/read_tree.c
@@ -199,6 +199,9 @@ int sqfs_dir_reader_get_full_hierarchy(sqfs_dir_reader_t *rd,
const char *ptr;
int ret;
+ if (flags & ~SQFS_TREE_ALL_FLAGS)
+ return SQFS_ERROR_UNSUPPORTED;
+
ret = sqfs_dir_reader_get_root_inode(rd, &inode);
if (ret)
return ret;
diff --git a/lib/sqfshelper/statistics.c b/lib/sqfshelper/statistics.c
index 3f9f595..fb70615 100644
--- a/lib/sqfshelper/statistics.c
+++ b/lib/sqfshelper/statistics.c
@@ -55,6 +55,7 @@ static void notify_fragment_discard(void *user, const sqfs_block_t *block)
}
static const sqfs_block_hooks_t hooks = {
+ .size = sizeof(hooks),
.post_block_write = post_block_write,
.pre_fragment_store = pre_fragment_store,
.notify_blocks_erased = notify_blocks_erased,