From 22da074ff7d663cef81d5599997431041f68fda4 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Fri, 3 Jun 2016 15:06:56 -0700 Subject: [PATCH] dll: fuse: fuse_opt_parse: bugfix in handling templates of the form NAME=VALUE --- src/dll/fuse/fuse_opt.c | 9 ++++++++- tst/winfsp-tests/fuse-opt-test.c | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dll/fuse/fuse_opt.c b/src/dll/fuse/fuse_opt.c index e7189e38..0cd66579 100644 --- a/src/dll/fuse/fuse_opt.c +++ b/src/dll/fuse/fuse_opt.c @@ -102,7 +102,14 @@ static void fsp_fuse_opt_match_templ( else if ('=' == *p) { if (*q == *p) - *pspec = p + 1, *parg = q + 1; + { + p++, q++; + if ('%' == *p || '\0' == *p) + *pspec = p, *parg = q; + else + *parg = 0 == lstrcmpA(q, p) ? + fsp_fuse_opt_match_exact : fsp_fuse_opt_match_none; + } else *parg = fsp_fuse_opt_match_none; break; diff --git a/tst/winfsp-tests/fuse-opt-test.c b/tst/winfsp-tests/fuse-opt-test.c index a61c5c51..6ce8554b 100644 --- a/tst/winfsp-tests/fuse-opt-test.c +++ b/tst/winfsp-tests/fuse-opt-test.c @@ -15,6 +15,7 @@ struct data long y; long long z; int dec, neg, hex, oct; + int sel; char *esc; int ESC; int arg_discard, arg_keep; int opt_discard, opt_keep; @@ -207,6 +208,10 @@ void fuse_opt_parse_test(void) { "--hex=%x", offsetof(struct data, hex), 'hex' }, { "--oct=%o", offsetof(struct data, oct), 'oct' }, + { "--sel=fortyone", offsetof(struct data, sel), 141 }, + { "--sel=fortytwo", offsetof(struct data, sel), 142 }, + { "--sel=fortythree", offsetof(struct data, sel), 143 }, + { "esc=%s", offsetof(struct data, esc), 'esc' }, FUSE_OPT_KEY("ESC=", 'ESC'), @@ -245,6 +250,7 @@ void fuse_opt_parse_test(void) "--neg=-1234567890", "--hex=ABCDEF", "--oct=12345670", + "--sel=fortytwo", "-oesc=\\\\foo\\,bar\\\\,ESC=\\\\FOO\\,BAR\\\\", "--discard", "--keep", @@ -317,6 +323,7 @@ void fuse_opt_parse_test(void) ASSERT(-1234567890 == data.neg); ASSERT(0xABCDEF == data.hex); ASSERT(012345670 == data.oct); + ASSERT(142 == data.sel); ASSERT(0 == strcmp("\\foo,bar\\", data.esc)); ASSERT(1 == data.ESC); ASSERT(1 == data.arg_discard);