diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2016-10-24 20:31:29 -0700 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2016-10-24 20:31:29 -0700 |
commit | b3ab365fda1a65f2c3535cda15de885bfa9de814 (patch) | |
tree | 8bd79452c1af07034d54aaf4f4ec04d873e85dc5 /lib/fuse_lowlevel.c | |
parent | 1d9f26f3736cc4703c2e988d87f5dd119bcd736d (diff) |
fuse_session_new(): don't accept empty argv, check argv[0]
This should help avoid people to accidentally put options
into argv[0].
Fixes #100.
Diffstat (limited to 'lib/fuse_lowlevel.c')
-rw-r--r-- | lib/fuse_lowlevel.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 8889d2d..3aa12de 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2739,6 +2739,11 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, op_size = sizeof(struct fuse_lowlevel_ops); } + if (args->argc == 0) { + fprintf(stderr, "fuse: empty argv passed to fuse_session_new().\n"); + return NULL; + } + se = (struct fuse_session *) calloc(1, sizeof(struct fuse_session)); if (se == NULL) { fprintf(stderr, "fuse: failed to allocate fuse object\n"); @@ -2754,7 +2759,12 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, goto out2; if(fuse_opt_parse(args, se, fuse_ll_opts, NULL) == -1) goto out3; - if (args->argc != 1) { + + if(args->argc == 1 && + args->argv[0][0] == '-') { + fprintf(stderr, "fuse: warning: argv[0] looks like an option, but " + "will be ignored\n"); + } else if (args->argc != 1) { int i; fprintf(stderr, "fuse: unknown option(s): `"); for(i = 1; i < args->argc-1; i++) |