summaryrefslogtreecommitdiff
path: root/unpack/restore_fstree.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-01 09:15:03 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-01 09:15:03 +0200
commit678261844d162112cc9268e8082be580f7218525 (patch)
tree71ff44fdc72a96561a7f2ed9743ff72da3b95b1d /unpack/restore_fstree.c
parenta585b2a1dacdb109f445b6599d22d719903461d5 (diff)
Fix null-pointer dereference in restore_unpack
Use a seperate variable to iterate over directory children and don't modify n. Otherwise, the chown/chmod code below derefernces a null pointer when trying to access n->name, n->uid and n->gid. Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack/restore_fstree.c')
-rw-r--r--unpack/restore_fstree.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c
index ab10f5d..455e604 100644
--- a/unpack/restore_fstree.c
+++ b/unpack/restore_fstree.c
@@ -3,6 +3,7 @@
static int create_node(tree_node_t *n, data_reader_t *data, int flags)
{
+ tree_node_t *c;
char *name;
int fd;
@@ -23,8 +24,8 @@ static int create_node(tree_node_t *n, data_reader_t *data, int flags)
if (pushd(n->name))
return -1;
- for (n = n->data.dir->children; n != NULL; n = n->next) {
- if (create_node(n, data, flags))
+ for (c = n->data.dir->children; c != NULL; c = c->next) {
+ if (create_node(c, data, flags))
return -1;
}