Blob Blame History Raw
autofs-5.0.7 - fix master map bogus keywork match

From: Ian Kent <raven@themaw.net>

If we have a map name in the master map that ends with a keyword
of one of the map types or "multi" we mistakenly match the trailing
white space and include that in the map name. This has to be wrong
since we can't handle quoting in the master map and embedded white
space must be escaped. It would be good if we handled quoted strings
but that has proven a bit of a nightmare so far for the current
tokenizer.
---
 CHANGELOG        |    1 +
 lib/master_tok.l |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 00eaff2..e15aa1f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -46,6 +46,7 @@
 - fix interface address null check.
 - dont probe rdma mounts.
 - fix master map mount options matching.
+- fix master map bogus keywork match.
 
 25/07/2012 autofs-5.0.7
 =======================
diff --git a/lib/master_tok.l b/lib/master_tok.l
index 8d1f1a2..a55cc76 100644
--- a/lib/master_tok.l
+++ b/lib/master_tok.l
@@ -202,6 +202,14 @@ OPTNTOUT	(-n{OPTWS}|-n{OPTWS}={OPTWS}|--negative-timeout{OPTWS}|--negative-timeo
 	{MULTI} {
 		tlen = master_leng - 1;
 		if (bptr != buff && isblank(master_text[tlen])) {
+			/*
+			 * We can't handle unescaped white space in map names
+			 * so just eat the white space. We always have the
+			 * "multi" at the beginning of the string so the while
+			 * will not fall off the end.
+			 */
+			while (isblank(master_text[tlen - 1]))
+				tlen--;
 			strncat(buff, master_text, tlen);
 			bptr += tlen;
 			yyless(tlen);
@@ -216,6 +224,14 @@ OPTNTOUT	(-n{OPTWS}|-n{OPTWS}={OPTWS}|--negative-timeout{OPTWS}|--negative-timeo
 	{MTYPE}/{DNATTRSTR}= {
 		tlen = master_leng - 1;
 		if (bptr != buff && isblank(master_text[tlen])) {
+			/*
+			 * We can't handle unescaped white space in map names
+			 * so just eat the white space. We always have the
+			 * maptype keyword at the beginning of the string so
+			 * the while will not fall off the end.
+			 */
+			while (isblank(master_text[tlen - 1]))
+				tlen--;
 			strncat(buff, master_text, tlen);
 			bptr += tlen;
 			yyless(tlen);