From aad5c3a44d4386b2128b956446b2c6295a4c28ad Mon Sep 17 00:00:00 2001 From: Goswin von Brederlow Date: Fri, 13 Jan 2023 10:36:52 +0100 Subject: [PATCH] Fix loading of FUSE modules dlsym returns the address of the module factory symbol, not the actual function (#722) pointer. Change the type of `factory` to `fuse_module_factory_t*` to reflect this and then dereference it when registering the module. This is a followup to d92bf83, which introduced a NULL pointer dereference when dlsym returns NULL, and 8ec7fd9, which reverted it back to not dereferencing the symbol at all. Fixes: #721 Co-authored-by: Goswin von Brederlow --- lib/fuse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fuse.c b/lib/fuse.c index 04b371f..9834f75 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -249,7 +249,7 @@ static int fuse_load_so_module(const char *module) int ret = -1; char *tmp; struct fusemod_so *so; - fuse_module_factory_t factory; + fuse_module_factory_t *factory; tmp = malloc(strlen(module) + 64); if (!tmp) { @@ -271,13 +271,13 @@ static int fuse_load_so_module(const char *module) } sprintf(tmp, "fuse_module_%s_factory", module); - *(void**)(&factory) = dlsym(so->handle, tmp); + factory = (fuse_module_factory_t*)dlsym(so->handle, tmp); if (factory == NULL) { fuse_log(FUSE_LOG_ERR, "fuse: symbol <%s> not found in module: %s\n", tmp, dlerror()); goto out_dlclose; } - ret = fuse_register_module(module, factory, so); + ret = fuse_register_module(module, *factory, so); if (ret) goto out_dlclose; -- 2.30.2