diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-08-19 15:57:11 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-08-19 15:59:00 +0200 |
commit | c40373dd16a15f187252b9b1d21a9ab588ece4de (patch) | |
tree | e708d8351f2d3de96658f06716f3031568031a92 /unpack/restore_fstree.c | |
parent | 13fc663dc37520a63ba05c71697d2763e16e30e0 (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/restore_fstree.c')
-rw-r--r-- | unpack/restore_fstree.c | 14 |
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; } |