aboutsummaryrefslogtreecommitdiff
path: root/unpack
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-19 15:57:11 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-19 15:59:00 +0200
commitc40373dd16a15f187252b9b1d21a9ab588ece4de (patch)
treee708d8351f2d3de96658f06716f3031568031a92 /unpack
parent13fc663dc37520a63ba05c71697d2763e16e30e0 (diff)
Fix directory traversal in update_tree_attribs
Do not try to change the nameless root node which is mapped to the output directory. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack')
-rw-r--r--unpack/restore_fstree.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c
index 2ee4c08..4e763cb 100644
--- a/unpack/restore_fstree.c
+++ b/unpack/restore_fstree.c
@@ -192,8 +192,20 @@ int restore_fstree(tree_node_t *root, int flags)
int update_tree_attribs(fstree_t *fs, tree_node_t *root, int flags)
{
+ tree_node_t *n;
+
if ((flags & (UNPACK_CHOWN | UNPACK_CHMOD | UNPACK_SET_TIMES)) == 0)
return 0;
- return set_attribs(fs, root, flags);
+ if (S_ISDIR(root->mode)) {
+ for (n = root->data.dir->children; n != NULL; n = n->next) {
+ if (set_attribs(fs, n, flags))
+ return -1;
+ }
+ } else {
+ if (set_attribs(fs, root, flags))
+ return -1;
+ }
+
+ return 0;
}