From 87dd817c4e17b478b08cd6cf9c63c45e695e64f1 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 26 May 2020 11:53:38 +0200 Subject: sqfsdiff: extract compressor options, but don't fail on error This commit modifies sqfsdiff to extract the compressor options from the squashfs image and store them in a compressor configuration if possible. The failure path is modified to *not* burst into flames on error, because those options are not required by any compressor to read data from the disk and pretty much every vendor modifed SquashFS has messed with those to the point that they cannot be propperly decoded (or the flag is set and there are no options). Signed-off-by: David Oberhollenzer --- bin/sqfsdiff/sqfsdiff.c | 11 +++++++++-- bin/sqfsdiff/sqfsdiff.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'bin/sqfsdiff') diff --git a/bin/sqfsdiff/sqfsdiff.c b/bin/sqfsdiff/sqfsdiff.c index 2871322..b543c00 100644 --- a/bin/sqfsdiff/sqfsdiff.c +++ b/bin/sqfsdiff/sqfsdiff.c @@ -40,10 +40,17 @@ static int open_sfqs(sqfs_state_t *state, const char *path) if (state->super.flags & SQFS_FLAG_COMPRESSOR_OPTIONS) { ret = state->cmp->read_options(state->cmp, state->file); - if (ret) { + + if (ret == 0) { + state->cmp->get_configuration(state->cmp, + &state->options); + state->have_options = true; + } else { sqfs_perror(path, "reading compressor options", ret); - goto fail_cmp; + state->have_options = false; } + } else { + state->have_options = false; } state->idtbl = sqfs_id_table_create(0); diff --git a/bin/sqfsdiff/sqfsdiff.h b/bin/sqfsdiff/sqfsdiff.h index 94fce93..a8f1b32 100644 --- a/bin/sqfsdiff/sqfsdiff.h +++ b/bin/sqfsdiff/sqfsdiff.h @@ -27,6 +27,9 @@ typedef struct { sqfs_dir_reader_t *dr; sqfs_tree_node_t *root; sqfs_data_reader_t *data; + + sqfs_compressor_config_t options; + bool have_options; } sqfs_state_t; typedef struct { -- cgit v1.2.3