libmount/optstr: trim leading commas from each opt
PATCH 1/1 libmount/optstr: trim leading commas from each opt
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 <[email protected]>
--- libmount/src/optstr.c | 5 +++++ 1 file changed, 5 insertions(+)
libmount/src/optstr.c +5 -0
@@ -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 */
Signature · 1 line
1.7.10.3
Quoted 2 lines · Dave Reisner
libmount/src/optstr.c | 5 +++++ 1 file changed, 5 insertions(+)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com