Skip to contentSkip to conversation

libmount/optstr: trim leading commas from each opt

PATCH Applied Dave Reisner 2 participants 2 messages Jun 3, 2012 – Jun 5, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

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.

---
 libmount/src/optstr.c |    5 +++++
 1 file changed, 5 insertions(+)
libmount/src/optstr.c +5 -0
index af5953b..66d2a06 100644
@@ -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
maintainer Applied
#1 lore raw
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