From 82416484063715c1fc22d3cca0d65d432d7a5076 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 19 Apr 2021 09:25:42 +0200 Subject: [PATCH 1/2] main: fix a memory leak on errors It was reported by static analysis. The resource is not really leaked since fuse-overlayfs exits immediately when load_default_plugins() fails. Signed-off-by: Giuseppe Scrivano --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 26cb24f..c61522c 100644 --- a/main.c +++ b/main.c @@ -5464,6 +5464,7 @@ load_default_plugins () if (asprintf (&new_plugins, "%s/%s:%s", PKGLIBEXECDIR, dent->d_name, plugins) < 0) { free (plugins); + closedir (dp); return NULL; } free (plugins); From a8d7c0b0f40cf34c0ab167fd05d950642d69ddaf Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 19 Apr 2021 09:32:12 +0200 Subject: [PATCH 2/2] main: avoid temporary copy use directly node->path instead of copying it to a temporary buffer. Signed-off-by: Giuseppe Scrivano --- main.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/main.c b/main.c index c61522c..2b04262 100644 --- a/main.c +++ b/main.c @@ -5033,7 +5033,6 @@ do_fsync (fuse_req_t req, fuse_ino_t ino, int datasync, int fd) struct ovl_node *node; struct ovl_data *lo = ovl_data (req); cleanup_lock int l = 0; - char path[PATH_MAX]; if (!lo->fsync) { @@ -5059,9 +5058,6 @@ do_fsync (fuse_req_t req, fuse_ino_t ino, int datasync, int fd) return; } - if (fd < 0) - strncpy (path, node->path, PATH_MAX); - if (! do_fsync) { fuse_reply_err (req, 0); @@ -5069,7 +5065,7 @@ do_fsync (fuse_req_t req, fuse_ino_t ino, int datasync, int fd) } if (do_fsync) - ret = direct_fsync (node->layer, fd, path, datasync); + ret = direct_fsync (node->layer, fd, node->path, datasync); fuse_reply_err (req, ret == 0 ? 0 : errno); }