summaryrefslogtreecommitdiffstats
path: root/libmount/src/optstr.c
diff options
context:
space:
mode:
authorDave Reisner2012-06-03 18:25:47 +0200
committerKarel Zak2012-06-05 15:40:11 +0200
commit5e7b834002aa0ce97a1b0104e8710664ad954595 (patch)
tree67726a758be4128d126d7fb1c326e1e9ad3a1277 /libmount/src/optstr.c
parentbuild-sys: include correct source file for chsh (diff)
downloadkernel-qcow2-util-linux-5e7b834002aa0ce97a1b0104e8710664ad954595.tar.gz
kernel-qcow2-util-linux-5e7b834002aa0ce97a1b0104e8710664ad954595.tar.xz
kernel-qcow2-util-linux-5e7b834002aa0ce97a1b0104e8710664ad954595.zip
libmount: trim leading commas from each options string
Fixes a bug in option string parsing wherein a line such as: ro,relatime,,nosuid,nodev Will be seen as only the tokens "ro" and "relatime" after the parser encounters a zero length (and erroneously declared NULL) option. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'libmount/src/optstr.c')
-rw-r--r--libmount/src/optstr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index af5953bc6..66d2a06c3 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -62,6 +62,11 @@ static int mnt_optstr_parse_next(char **optstr, char **name, size_t *namesz,
if (valsz)
*valsz = 0;
+ /* trim leading commas as to not invalidate option
+ * strings with multiple consecutive commas */
+ while (optstr0 && *optstr0 == ',')
+ optstr0++;
+
for (p = optstr0; p && *p; p++) {
if (!start)
start = p; /* begin of the option item */