From 535808c4d93e4637577aa17bf8413a41920dd2d8 Mon Sep 17 00:00:00 2001 From: Joanne Koong Date: Mon, 7 Oct 2024 13:37:20 -0700 Subject: 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. --- lib/fuse_loop_mt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/fuse_loop_mt.c') diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index ecf8af8..075ac2e 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -13,6 +13,7 @@ #include "fuse_misc.h" #include "fuse_kernel.h" #include "fuse_i.h" +#include "util.h" #include #include @@ -220,8 +221,17 @@ int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg) */ pthread_attr_init(&attr); stack_size = getenv(ENVNAME_THREAD_STACK); - if (stack_size && pthread_attr_setstacksize(&attr, atoi(stack_size))) - fuse_log(FUSE_LOG_ERR, "fuse: invalid stack size: %s\n", stack_size); + if (stack_size) { + long size; + + res = libfuse_strtol(stack_size, &size); + if (res) + fuse_log(FUSE_LOG_ERR, "fuse: invalid stack size: %s\n", + stack_size); + else if (pthread_attr_setstacksize(&attr, size)) + fuse_log(FUSE_LOG_ERR, "fuse: could not set stack size: %ld\n", + size); + } /* Disallow signal reception in worker threads */ sigemptyset(&newset); -- cgit v1.2.3