From 7f81935f32e58e8fec22bc46683b1b067469405f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 10 May 2022 10:44:34 +0200 Subject: [PATCH] Returned an error code when the --help or --version options are used Accepting --help or --version options may leave the ntfs-3g process in an unclean state, so reject them while processing options. Also reject them in libfuse-lite. --- libfuse-lite/mount.c | 3 +-- src/ntfs-3g_common.c | 6 ++++++ src/ntfs-3g_common.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libfuse-lite/mount.c b/libfuse-lite/mount.c index 64adee7d..6ae29d8c 100644 --- a/libfuse-lite/mount.c +++ b/libfuse-lite/mount.c @@ -670,11 +670,10 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args) fprintf(stderr, "fuse: 'allow_other' and 'allow_root' options are mutually exclusive\n"); goto out; } - res = 0; + res = -1; if (mo.ishelp) goto out; - res = -1; if (get_mnt_flag_opts(&mnt_opts, mo.flags) == -1) goto out; #ifndef __SOLARIS__ diff --git a/src/ntfs-3g_common.c b/src/ntfs-3g_common.c index 7e3e93d2..29021dfc 100644 --- a/src/ntfs-3g_common.c +++ b/src/ntfs-3g_common.c @@ -128,6 +128,10 @@ const struct DEFOPTION optionlist[] = { { "efs_raw", OPT_EFS_RAW, FLGOPT_BOGUS }, { "posix_nlink", OPT_POSIX_NLINK, FLGOPT_BOGUS }, { "special_files", OPT_SPECIAL_FILES, FLGOPT_STRING }, + { "--help", OPT_HELP, FLGOPT_BOGUS }, + { "-h", OPT_HELP, FLGOPT_BOGUS }, + { "--version", OPT_VERSION, FLGOPT_BOGUS }, + { "-V", OPT_VERSION, FLGOPT_BOGUS }, { (const char*)NULL, 0, 0 } /* end marker */ } ; @@ -521,6 +525,8 @@ char *parse_mount_options(ntfs_fuse_context_t *ctx, * mounted or not. * (falling through to default) */ + case OPT_HELP : /* Could lead to unclean condition */ + case OPT_VERSION : /* Could lead to unclean condition */ default : ntfs_log_error("'%s' is an unsupported option.\n", poptl->name); diff --git a/src/ntfs-3g_common.h b/src/ntfs-3g_common.h index 4ed256a3..8ead5107 100644 --- a/src/ntfs-3g_common.h +++ b/src/ntfs-3g_common.h @@ -94,6 +94,8 @@ enum { OPT_EFS_RAW, OPT_POSIX_NLINK, OPT_SPECIAL_FILES, + OPT_HELP, + OPT_VERSION, } ; /* Option flags */