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.
pull/40/head
Jean-Pierre André 2022-05-10 10:44:34 +02:00
parent bce5734a75
commit 7f81935f32
3 changed files with 9 additions and 2 deletions

View File

@ -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__

View File

@ -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);

View File

@ -94,6 +94,8 @@ enum {
OPT_EFS_RAW,
OPT_POSIX_NLINK,
OPT_SPECIAL_FILES,
OPT_HELP,
OPT_VERSION,
} ;
/* Option flags */