containerfs: fix fd leak

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2018-07-09 11:55:47 +02:00
parent 003d569b74
commit d7f52737d3
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

10
main.c
View File

@ -1521,12 +1521,20 @@ do_rm (fuse_req_t req, fuse_ino_t parent, const char *name, bool dirp)
{
DIR *dp;
size_t c = 0;
int fd = openat (get_upper_layer (lo)->fd, node->path, O_DIRECTORY);
int fd;
fd = openat (get_upper_layer (lo)->fd, node->path, O_DIRECTORY);
if (fd < 0)
{
fuse_reply_err (req, errno);
return;
}
if (node->children)
c = count_dir_entries (node);
if (c)
{
close (fd);
fuse_reply_err (req, ENOTEMPTY);
return;
}