From: Dave Reisner <dreisner@archlinux.org>
To: util-linux@vger.kernel.org
Cc: Dave Reisner <dreisner@archlinux.org>
Subject: [PATCH] libmount/optstr: trim leading commas from each opt
Date: Sun, 3 Jun 2012 12:25:47 -0400 [thread overview]
Message-ID: <1338740747-1809-1-git-send-email-dreisner@archlinux.org> (raw)
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 | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index af5953b..66d2a06 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 */
--
1.7.10.3
next reply other threads:[~2012-06-03 16:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-03 16:25 Dave Reisner [this message]
2012-06-05 13:50 ` [PATCH] libmount/optstr: trim leading commas from each opt Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338740747-1809-1-git-send-email-dreisner@archlinux.org \
--to=dreisner@archlinux.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).