summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhelg <helg@cvs.openbsd.org>2017-12-11 12:38:55 +0000
committerhelg <helg@cvs.openbsd.org>2017-12-11 12:38:55 +0000
commitfad941588d9afb4a8539ff43a430f8d4f291d822 (patch)
treecd0cdb685917f1efedce1a81e2e26c1e6f86a36e /lib
parent92b6179204b5d676b419e1e1141287275f94cfec (diff)
sscanf(3) is now used to parse templates that contain format specifiers
(e.g. %u, %o) other than %s. This aligns libfuse with the Linux reference implementation. ok mpi@
Diffstat (limited to 'lib')
-rw-r--r--lib/libfuse/fuse_opt.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/libfuse/fuse_opt.c b/lib/libfuse/fuse_opt.c
index aa5436b4b4e..e7ec4168604 100644
--- a/lib/libfuse/fuse_opt.c
+++ b/lib/libfuse/fuse_opt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_opt.c,v 1.21 2017/12/11 12:31:00 helg Exp $ */
+/* $OpenBSD: fuse_opt.c,v 1.22 2017/12/11 12:38:54 helg Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
* Copyright (c) 2013 Stefan Sperling <stsp@openbsd.org>
@@ -233,18 +233,16 @@ parse_opt(const struct fuse_opt *o, const char *opt, void *data,
} else if (strchr(o->templ, '%') == NULL) {
*((int *)(data + o->off)) = o->val;
ret = IFUSE_OPT_DISCARD;
- } else if (strstr(o->templ, "%u") != NULL) {
- *((unsigned int*)(data + o->off)) = atoi(val);
- ret = IFUSE_OPT_DISCARD;
- } else if (strstr(o->templ, "%lu") != NULL) {
- *((unsigned long*)(data + o->off)) =
- strtoul(val, NULL, 0);
- ret = IFUSE_OPT_DISCARD;
} else if (strstr(o->templ, "%s") != NULL) {
*((char **)(data + o->off)) = strdup(val);
ret = IFUSE_OPT_DISCARD;
} else {
- /* TODO other parameterised templates */
+ /* All other templates, let sscanf deal with them. */
+ if (sscanf(opt, o->templ, data + o->off) != 1) {
+ fprintf(stderr, "fuse: Invalid value %s for "
+ "option %s\n", val, o->templ);
+ return (-1);
+ }
ret = IFUSE_OPT_DISCARD;
}
}