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 18:11:00 +0100
commit3232d6e05fed808878ef8ae86af348a94f0da585 (patch)
treeedb77fd3dd890d0aad2f006909e65fe636da1429
parent42824c4afc7da568b3a1914c5e5954049d71f253 (diff)
downloadlibfuse-3232d6e05fed808878ef8ae86af348a94f0da585.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");