aboutsummaryrefslogtreecommitdiffstats
path: root/util/fusermount.c
diff options
context:
space:
mode:
authorJoanne Koong <joannelkoong@gmail.com>2024-10-07 13:37:20 -0700
committerBernd Schubert <bernd.schubert@fastmail.fm>2024-10-11 13:15:38 +0200
commit535808c4d93e4637577aa17bf8413a41920dd2d8 (patch)
tree823ce1f443beeb98ec5a1ae997375b8d70161014 /util/fusermount.c
parent55eb214db9fa6c16f0af6a4e1a70b56b959aee3e (diff)
downloadlibfuse-535808c4d93e4637577aa17bf8413a41920dd2d8.tar.gz
Add libfuse util strtol wrapper
Add a wrapper around strtol for more rigorous error checking and convert uses of atoi and strtol to use this instead.
Diffstat (limited to 'util/fusermount.c')
-rw-r--r--util/fusermount.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/util/fusermount.c b/util/fusermount.c
index 8528342..b87d8bb 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
@@ -10,6 +10,7 @@
#define _GNU_SOURCE /* for clone and strchrnul */
#include "fuse_config.h"
#include "mount_util.h"
+#include "util.h"
#include <stdio.h>
#include <stdlib.h>
@@ -1500,7 +1501,7 @@ int main(int argc, char *argv[])
static int lazy = 0;
static int quiet = 0;
char *commfd = NULL;
- int cfd;
+ long cfd;
const char *opts = "";
const char *type = NULL;
int setup_auto_unmount_only = 0;
@@ -1604,13 +1605,20 @@ int main(int argc, char *argv[])
goto err_out;
}
- cfd = atoi(commfd);
+ res = libfuse_strtol(commfd, &cfd);
+ if (res) {
+ fprintf(stderr,
+ "%s: invalid _FUSE_COMMFD: %s\n",
+ progname, commfd);
+ goto err_out;
+
+ }
{
struct stat statbuf;
fstat(cfd, &statbuf);
if(!S_ISSOCK(statbuf.st_mode)) {
fprintf(stderr,
- "%s: file descriptor %i is not a socket, can't send fuse fd\n",
+ "%s: file descriptor %li is not a socket, can't send fuse fd\n",
progname, cfd);
goto err_out;
}