From: Vassili Tchersky Date: Mon, 17 Feb 2025 07:50:19 +0000 (+0100) Subject: mount_bsd: Fix usage of libfuse_strtol X-Git-Tag: fuse-3.17.1-rc1~8 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=fa1c84d0e0a60db855aa42aab4363624c6796e70;p=qemu-gpiodev%2Flibfuse.git 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 --- 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 #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");