From facb69730396d5b033cd2289903a00d1b645b2fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Pierre=20Andr=C3=A9?= Date: Wed, 23 Jan 2019 17:33:15 +0100 Subject: [PATCH] Fixed reacting to missing plugin When a plugin is missing, dlopen() does not set errno, which leads to erratic behavior. Set errno as ELIBACC when this occurs. --- include/ntfs-3g/compat.h | 7 ++++++- src/lowntfs-3g.c | 9 ++++----- src/ntfs-3g_common.c | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/ntfs-3g/compat.h b/include/ntfs-3g/compat.h index ded6c5f8..fa57a38a 100644 --- a/include/ntfs-3g/compat.h +++ b/include/ntfs-3g/compat.h @@ -1,9 +1,10 @@ /* - * compat.h - Tweaks for Windows compatibility. + * compat.h - Tweaks for compatibility with non-Linux systems. * * Copyright (c) 2002 Richard Russon * Copyright (c) 2002-2004 Anton Altaparmakov * Copyright (c) 2008-2009 Szabolcs Szakacsits + * Copyright (c) 2019 Jean-Pierre Andre * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -41,6 +42,10 @@ #define ELIBBAD ENOEXEC #endif +#ifndef ELIBACC +#define ELIBACC ENOENT +#endif + #ifndef PATH_MAX #define PATH_MAX 4096 #endif diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index 26d6eca5..983ab010 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -4,7 +4,7 @@ * Copyright (c) 2005-2007 Yura Pakhuchiy * Copyright (c) 2005 Yuval Fledel * Copyright (c) 2006-2009 Szabolcs Szakacsits - * Copyright (c) 2007-2017 Jean-Pierre Andre + * Copyright (c) 2007-2019 Jean-Pierre Andre * Copyright (c) 2009 Erik Larsson * * This file is originated from the Linux-NTFS project. @@ -263,7 +263,7 @@ static const char *usage_msg = "\n" "Copyright (C) 2005-2007 Yura Pakhuchiy\n" "Copyright (C) 2006-2009 Szabolcs Szakacsits\n" -"Copyright (C) 2007-2017 Jean-Pierre Andre\n" +"Copyright (C) 2007-2019 Jean-Pierre Andre\n" "Copyright (C) 2009 Erik Larsson\n" "\n" "Usage: %s [-o option[,...]] \n" @@ -1074,10 +1074,9 @@ static void ntfs_fuse_readlink(fuse_req_t req, fuse_ino_t ino) REPARSE_POINT *reparse; res = CALL_REPARSE_PLUGIN(ni, readlink, &buf); - if (res) { + if (res || !buf) { buf = strdup(ntfs_bad_reparse); - if (!buf) - res = -errno; + res = (buf ? 0 : -errno); } #else /* DISABLE_PLUGINS */ errno = 0; diff --git a/src/ntfs-3g_common.c b/src/ntfs-3g_common.c index 20a82dec..a8ea6385 100644 --- a/src/ntfs-3g_common.c +++ b/src/ntfs-3g_common.c @@ -1,7 +1,7 @@ /** * ntfs-3g_common.c - Common definitions for ntfs-3g and lowntfs-3g. * - * Copyright (c) 2010-2018 Jean-Pierre Andre + * Copyright (c) 2010-2019 Jean-Pierre Andre * Copyright (c) 2010 Erik Larsson * * This program/include file is free software; you can redistribute it and/or @@ -841,6 +841,7 @@ const struct plugin_operations *select_reparse_plugin(ntfs_fuse_context_t *ctx, if (!ops) dlclose(handle); } else { + errno = ELIBACC; if (!(ctx->errors_logged & ERR_PLUGIN)) { ntfs_log_perror( "Could not load plugin %s", -- 2.11.0