summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlixiaokeng <63774002+lixiaokeng@users.noreply.github.com>2021-09-06 20:37:45 +0800
committerGitHub <noreply@github.com>2021-09-06 13:37:45 +0100
commitaaf767a6cc20f3f48c161b71cfdf297c1bc97e72 (patch)
tree18d25ff5cebc9c1a5af77fb5d1e5d233dab5aec5
parent9677eca556ca15a5899f4953c13783f834917ee0 (diff)
downloadfuse-aaf767a6cc20f3f48c161b71cfdf297c1bc97e72.tar.gz
Fix: fd and memory leak in mount.fuse.c (#614)
The command isn't freed and the fuse_fd isn't closed if execl failed. Fix it. Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
-rw-r--r--util/mount.fuse.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/mount.fuse.c b/util/mount.fuse.c
index f7e60c7..a6e5629 100644
--- a/util/mount.fuse.c
+++ b/util/mount.fuse.c
@@ -243,6 +243,7 @@ int main(int argc, char *argv[])
int dev = 1;
int suid = 1;
int pass_fuse_fd = 0;
+ int fuse_fd = 0;
int drop_privileges = 0;
char *dev_fd_mountpoint = NULL;
@@ -413,7 +414,7 @@ int main(int argc, char *argv[])
}
if (pass_fuse_fd) {
- int fuse_fd = prepare_fuse_fd(mountpoint, type, options);
+ fuse_fd = prepare_fuse_fd(mountpoint, type, options);
dev_fd_mountpoint = xrealloc(NULL, 20);
snprintf(dev_fd_mountpoint, 20, "/dev/fd/%u", fuse_fd);
mountpoint = dev_fd_mountpoint;
@@ -441,5 +442,9 @@ int main(int argc, char *argv[])
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
fprintf(stderr, "%s: failed to execute /bin/sh: %s\n", progname,
strerror(errno));
+
+ if (pass_fuse_fd)
+ close(fuse_fd);
+ free(command);
return 1;
}