From 75063b2e14dacc13fcbeeba24e580198a7c1c638 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 5 Jul 2022 12:16:36 +0200 Subject: Make sqfs_tree_node_get_path more robust Test against various invariants: - Every non-root node must have a name - The root node muts not have a name - The name must not be ".." or "." - The name must not contain '/' - The loop that chases parent pointers must terminate, i.e. we must never reach the starting state again (link loop). Furthermore, make sure the sum of all path components plus separators does not overflow. Signed-off-by: David Oberhollenzer --- bin/sqfs2tar/write_tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin/sqfs2tar') diff --git a/bin/sqfs2tar/write_tree.c b/bin/sqfs2tar/write_tree.c index d4f8366..1c19a5a 100644 --- a/bin/sqfs2tar/write_tree.c +++ b/bin/sqfs2tar/write_tree.c @@ -102,9 +102,9 @@ static int write_tree_dfs(const sqfs_tree_node_t *n) return 0; } - name = sqfs_tree_node_get_path(n); - if (name == NULL) { - perror("resolving tree node path"); + ret = sqfs_tree_node_get_path(n, &name); + if (ret != 0) { + sqfs_perror(NULL, "resolving tree node path", ret); return -1; } -- cgit v1.2.3