aboutsummaryrefslogtreecommitdiff
path: root/unpack
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-04 22:57:29 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-04 22:57:29 +0200
commit09bdcdb1f3f2d7810ea956842bc7551d9ca26f92 (patch)
tree75ceaf52f2ca54725d4de01d931d8ca75ef7ad35 /unpack
parent363de21c65fab165851fae1f8ef9665edb1ff508 (diff)
rdsquashfs: more cleanup
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack')
-rw-r--r--unpack/rdsquashfs.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c
index deba5be..3c80853 100644
--- a/unpack/rdsquashfs.c
+++ b/unpack/rdsquashfs.c
@@ -110,6 +110,26 @@ static char *get_path(char *old, const char *arg)
return path;
}
+static int load_fragment_table(unsqfs_info_t *info, sqfs_super_t *super)
+{
+ if (super->fragment_entry_count == 0)
+ return 0;
+
+ if (super->flags & SQFS_FLAG_NO_FRAGMENTS)
+ return 0;
+
+ if (super->fragment_table_start >= super->bytes_used) {
+ fputs("Fragment table start is past end of file\n", stderr);
+ return -1;
+ }
+
+ info->frag = frag_reader_create(super, info->sqfsfd, info->cmp);
+ if (info->frag == NULL)
+ return -1;
+
+ return 0;
+}
+
int main(int argc, char **argv)
{
int i, status = EXIT_FAILURE, op = OP_NONE;
@@ -251,14 +271,8 @@ int main(int argc, char **argv)
goto out_fs;
}
- if (super.fragment_entry_count > 0 &&
- super.fragment_table_start < super.bytes_used &&
- !(super.flags & SQFS_FLAG_NO_FRAGMENTS)) {
- info.frag = frag_reader_create(&super, info.sqfsfd,
- info.cmp);
- if (info.frag == NULL)
- goto out_fs;
- }
+ if (load_fragment_table(&info, &super))
+ goto out_fs;
if (extract_file(n->data.file, &info, STDOUT_FILENO))
goto out_fs;
@@ -274,14 +288,8 @@ int main(int argc, char **argv)
}
}
- if (super.fragment_entry_count > 0 &&
- super.fragment_table_start < super.bytes_used &&
- !(super.flags & SQFS_FLAG_NO_FRAGMENTS)) {
- info.frag = frag_reader_create(&super, info.sqfsfd,
- info.cmp);
- if (info.frag == NULL)
- goto out_fs;
- }
+ if (load_fragment_table(&info, &super))
+ goto out_fs;
if (restore_fstree(unpack_root, n, &info))
goto out_fs;