aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVassili Tchersky <vt+git@vbcy.org>2025-02-17 08:50:19 +0100
committerBernd Schubert <bernd@bsbernd.com>2025-02-18 22:32:49 +0100
commitfa1c84d0e0a60db855aa42aab4363624c6796e70 (patch)
treea58e733df8b5cba146b61e90a279b5508454d7ac
parent13cdf97c0315197b57feba073070ea6a4f834eef (diff)
downloadlibfuse-fa1c84d0e0a60db855aa42aab4363624c6796e70.tar.gz
mount_bsd: Fix usage of libfuse_strtol
The check on fd < 0 was recently removed. However, this check is important as the content of FUSE_DEV_FD is passed as-is to mount_fusefs, and a string beginning by '-' is treated as an option. Additionally, add a proper include and type. Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
-rw-r--r--lib/mount_bsd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/mount_bsd.c b/lib/mount_bsd.c
index 1863c49..85332d3 100644
--- a/lib/mount_bsd.c
+++ b/lib/mount_bsd.c
@@ -12,6 +12,7 @@
#include "fuse_i.h"
#include "fuse_misc.h"
#include "fuse_opt.h"
+#include "util.h"
#include <sys/param.h>
#include "fuse_mount_compat.h"
@@ -151,7 +152,7 @@ static int init_backgrounded(void)
static int fuse_mount_core(const char *mountpoint, const char *opts)
{
const char *mountprog = FUSERMOUNT_PROG;
- int fd;
+ long fd;
char *fdnam, *dev;
pid_t pid, cpid;
int status;
@@ -161,7 +162,7 @@ static int fuse_mount_core(const char *mountpoint, const char *opts)
if (fdnam) {
err = libfuse_strtol(fdnam, &fd);
- if (err) {
+ if (err || fd < 0) {
fuse_log(FUSE_LOG_ERR, "invalid value given in FUSE_DEV_FD\n");
return -1;
}
@@ -216,7 +217,7 @@ mount:
if (! fdnam)
{
- ret = asprintf(&fdnam, "%d", fd);
+ ret = asprintf(&fdnam, "%ld", fd);
if(ret == -1)
{
perror("fuse: failed to assemble mount arguments");