aboutsummaryrefslogtreecommitdiff
path: root/bin/rdsquashfs/describe.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-05 12:16:36 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-08 19:17:35 +0200
commit75063b2e14dacc13fcbeeba24e580198a7c1c638 (patch)
treef58b8c85ed5472523a5596be3434f7488dbfe465 /bin/rdsquashfs/describe.c
parent3946cf086183f8dd4d5d115f52ba1b87560b7ce4 (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/rdsquashfs/describe.c')
-rw-r--r--bin/rdsquashfs/describe.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/rdsquashfs/describe.c b/bin/rdsquashfs/describe.c
index 1e723bc..540b126 100644
--- a/bin/rdsquashfs/describe.c
+++ b/bin/rdsquashfs/describe.c
@@ -8,10 +8,12 @@
static int print_name(const sqfs_tree_node_t *n, bool dont_escape)
{
- char *start, *ptr, *name = sqfs_tree_node_get_path(n);
+ char *start, *ptr, *name;
+ int ret;
- if (name == NULL) {
- perror("Recovering file path of tree node");
+ ret = sqfs_tree_node_get_path(n, &name);
+ if (ret != 0) {
+ sqfs_perror(NULL, "Recovering file path of tree node", ret);
return -1;
}