]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: trim leading commas from each options string
authorDave Reisner <dreisner@archlinux.org>
Sun, 3 Jun 2012 16:25:47 +0000 (12:25 -0400)
committerKarel Zak <kzak@redhat.com>
Tue, 5 Jun 2012 13:40:11 +0000 (15:40 +0200)
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>
libmount/src/optstr.c

index af5953bc61ee02d72dacb99e387f0ce69426a917..66d2a06c39263a9a0b261883266623102167402d 100644 (file)
@@ -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 */