aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse_lowlevel.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 /lib/fuse_lowlevel.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 'lib/fuse_lowlevel.c')
-rw-r--r--lib/fuse_lowlevel.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index a505552..ef1cda5 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -17,6 +17,7 @@
#include "fuse_opt.h"
#include "fuse_misc.h"
#include "mount_util.h"
+#include "util.h"
#include <stdio.h>
#include <stdlib.h>
@@ -665,9 +666,9 @@ static int read_back(int fd, char *buf, size_t len)
static int grow_pipe_to_max(int pipefd)
{
- int max;
int res;
- int maxfd;
+ long max;
+ long maxfd;
char buf[32];
maxfd = open("/proc/sys/fs/pipe-max-size", O_RDONLY);
@@ -685,7 +686,9 @@ static int grow_pipe_to_max(int pipefd)
close(maxfd);
buf[res] = '\0';
- max = atoi(buf);
+ res = libfuse_strtol(buf, &max);
+ if (res)
+ return res;
res = fcntl(pipefd, F_SETPIPE_SZ, max);
if (res < 0)
return -errno;
@@ -2907,8 +2910,9 @@ static void fuse_ll_pipe_destructor(void *data)
static unsigned int get_max_pages(void)
{
char buf[32];
- int res;
+ long res;
int fd;
+ int err;
fd = open("/proc/sys/fs/fuse/max_pages_limit", O_RDONLY);
if (fd < 0)
@@ -2923,8 +2927,8 @@ static unsigned int get_max_pages(void)
buf[res] = '\0';
- res = strtol(buf, NULL, 10);
- return res < 0 ? FUSE_DEFAULT_MAX_PAGES_LIMIT : res;
+ err = libfuse_strtol(buf, &res);
+ return err ? FUSE_DEFAULT_MAX_PAGES_LIMIT : res;
}
int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf)