From e21bf0b60c1b9d67fe7553105b6440c3fce7c0bb Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 7 Oct 2019 15:54:41 +0200 Subject: Do an explicit "is filename sane" check Until now, filenames containing '/' or being equal to '..' or '.' where not handled explicitly, because they are canonicalized later, which will then fail. This commit adds an explicit check to make those fail immediately with a clear, specific error message. Signed-off-by: David Oberhollenzer --- unpack/fill_files.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'unpack/fill_files.c') diff --git a/unpack/fill_files.c b/unpack/fill_files.c index 481c398..e6444b2 100644 --- a/unpack/fill_files.c +++ b/unpack/fill_files.c @@ -114,6 +114,12 @@ static void clear_file_list(void) static int gen_file_list_dfs(const sqfs_tree_node_t *n) { + if (!is_filename_sane((const char *)n->name)) { + fprintf(stderr, "Found an entry named '%s', skipping.\n", + n->name); + return 0; + } + if (S_ISREG(n->inode->base.mode)) return add_file(n); -- cgit v1.2.3