diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2010-09-28 10:13:24 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2010-09-28 10:13:24 +0200 |
commit | 914b4b15681775736cb16d0521a37dfd40cf1b85 (patch) | |
tree | 6e3db04442b7f358aecfd6cda7ff639835dd5762 | |
parent | 6433d1b8cbd8c7befaf50922858632daf2b33c8f (diff) | |
download | fuse-914b4b15681775736cb16d0521a37dfd40cf1b85.tar.gz |
Fix option escaping for fusermount.
If the "fsname=" option contained a comma then the option parser in
fusermount was confused (Novell bugzilla #641480). Fix by escaping
commas when passing them over to fusermount.
Reported by Jan Engelhardt
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/mount.c | 2 | ||||
-rw-r--r-- | util/fusermount.c | 20 |
3 files changed, 25 insertions, 4 deletions
@@ -1,3 +1,10 @@ +2010-09-28 Miklos Szeredi <miklos@szeredi.hu> + + * Fix option escaping for fusermount. If the "fsname=" option + contained a comma then the option parser in fusermount was + confused (Novell bugzilla #641480). Fix by escaping commas when + passing them over to fusermount. Reported by Jan Engelhardt + 2010-05-10 Miklos Szeredi <miklos@szeredi.hu> * Remove "chmod root" from install of fusermount. Reported by diff --git a/lib/mount.c b/lib/mount.c index c3b16a4..73b1d9b 100644 --- a/lib/mount.c +++ b/lib/mount.c @@ -200,7 +200,7 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key, return fuse_opt_add_opt(&mo->kernel_opts, arg); case KEY_FUSERMOUNT_OPT: - return fuse_opt_add_opt(&mo->fusermount_opts, arg); + return fuse_opt_add_opt_escaped(&mo->fusermount_opts, arg); case KEY_SUBTYPE_OPT: return fuse_opt_add_opt(&mo->subtype_opt, arg); diff --git a/util/fusermount.c b/util/fusermount.c index ae779d3..39da9b6 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -649,7 +649,9 @@ static int opt_eq(const char *s, unsigned len, const char *opt) static int get_string_opt(const char *s, unsigned len, const char *opt, char **val) { + int i; unsigned opt_len = strlen(opt); + char *d; if (*val) free(*val); @@ -659,8 +661,15 @@ static int get_string_opt(const char *s, unsigned len, const char *opt, return 0; } - memcpy(*val, s + opt_len, len - opt_len); - (*val)[len - opt_len] = '\0'; + d = *val; + s += opt_len; + len -= opt_len; + for (i = 0; i < len; i++) { + if (s[i] == '\\' && i + 1 < len) + i++; + *d++ = s[i]; + } + *d = '\0'; return 1; } @@ -691,7 +700,12 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode, unsigned len; const char *fsname_str = "fsname="; const char *subtype_str = "subtype="; - for (len = 0; s[len] && s[len] != ','; len++); + for (len = 0; s[len]; len++) { + if (s[len] == '\\' && s[len + 1]) + len++; + else if (s[len] == ',') + break; + } if (begins_with(s, fsname_str)) { if (!get_string_opt(s, len, fsname_str, &fsname)) goto err; |