fuse-overlayfs: add check to readdir for the node parent

ensure the node was not moved and that its parent is the same as the
directory we are reading.

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
This commit is contained in:
Giuseppe Scrivano 2019-02-16 10:00:20 +01:00 committed by Giuseppe Scrivano
parent 3ff2c01cbb
commit 43b6b2ecf9
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

6
main.c
View File

@ -1257,6 +1257,7 @@ ovl_lookup (fuse_req_t req, fuse_ino_t parent, const char *name)
struct ovl_dirp struct ovl_dirp
{ {
struct ovl_data *lo; struct ovl_data *lo;
struct ovl_node *parent;
struct ovl_node **tbl; struct ovl_node **tbl;
size_t tbl_size; size_t tbl_size;
size_t offset; size_t offset;
@ -1304,6 +1305,7 @@ ovl_opendir (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
goto out_errno; goto out_errno;
d->offset = 0; d->offset = 0;
d->parent = node;
d->tbl_size = hash_get_n_entries (node->children) + 2; d->tbl_size = hash_get_n_entries (node->children) + 2;
d->tbl = malloc (sizeof (struct ovl_node *) * d->tbl_size); d->tbl = malloc (sizeof (struct ovl_node *) * d->tbl_size);
if (d->tbl == NULL) if (d->tbl == NULL)
@ -1460,7 +1462,11 @@ ovl_do_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
else if (offset == 1) else if (offset == 1)
name = ".."; name = "..";
else else
{
if (node->parent != d->parent)
continue;
name = node->name; name = node->name;
}
if (!plus) if (!plus)
entsize = fuse_add_direntry (req, p, remaining, name, &st, offset + 1); entsize = fuse_add_direntry (req, p, remaining, name, &st, offset + 1);