Blame SOURCES/autofs-5.1.3-fix-expandamdent-quote-handling.patch

306fa1
autofs-5.1.3 - fix expandamdent() quote handling
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
The amd map entry option value expansion isn't quite right.
306fa1
306fa1
It shouldn't be possible to get double quotes in a map entry option
306fa1
value, only single quotes should be seen. And within single quotes
306fa1
only expand ${} macros.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG        |    1 +
306fa1
 lib/parse_subs.c |   23 ++++++-----------------
306fa1
 2 files changed, 7 insertions(+), 17 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -275,6 +275,7 @@
306fa1
 - fix amd defaults map entry handling.
306fa1
 - refactor amd_parse.c.
306fa1
 - fix amd parser double quote handling.
306fa1
+- fix expandamdent() quote handling.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/lib/parse_subs.c
306fa1
+++ autofs-5.0.7/lib/parse_subs.c
306fa1
@@ -1028,12 +1028,12 @@ static char *expand_slash_or_dot(char *s
306fa1
  * $-expand an amd-style map entry and return the length of the entry.
306fa1
  * If "dst" is NULL, just count the length.
306fa1
  */
306fa1
-/* TODO: how should quoting be handled? */
306fa1
 int expandamdent(const char *src, char *dst, const struct substvar *svc)
306fa1
 {
306fa1
 	unsigned int flags = conf_amd_get_flags(NULL);
306fa1
 	const struct substvar *sv;
306fa1
 	const char *o_src = src;
306fa1
+	unsigned int squote = 0;
306fa1
 	int len, l;
306fa1
 	const char *p;
306fa1
 	char ch;
306fa1
@@ -1104,7 +1104,7 @@ int expandamdent(const char *src, char *
306fa1
 			break;
306fa1
 
306fa1
 		case '\\':
306fa1
-			if (!(flags & CONF_NORMALIZE_SLASHES)) {
306fa1
+			if (squote || !(flags & CONF_NORMALIZE_SLASHES)) {
306fa1
 				len++;
306fa1
 				if (dst)
306fa1
 					*dst++ = ch;
306fa1
@@ -1124,7 +1124,7 @@ int expandamdent(const char *src, char *
306fa1
 			if (dst)
306fa1
 				*dst++ = ch;
306fa1
 
306fa1
-			if (!(flags & CONF_NORMALIZE_SLASHES))
306fa1
+			if (squote || !(flags & CONF_NORMALIZE_SLASHES))
306fa1
 				break;
306fa1
 
306fa1
 			/* Double slash at start is allowed */
306fa1
@@ -1138,23 +1138,12 @@ int expandamdent(const char *src, char *
306fa1
 				src++;
306fa1
 			break;
306fa1
 
306fa1
-		case '"':
306fa1
+		/* 39 is single quote */
306fa1
+		case 39:
306fa1
 			len++;
306fa1
 			if (dst)
306fa1
 				*dst++ = ch;
306fa1
-
306fa1
-			while (*src && *src != '"') {
306fa1
-				len++;
306fa1
-				if (dst)
306fa1
-					*dst++ = *src;
306fa1
-				src++;
306fa1
-			}
306fa1
-			if (*src) {
306fa1
-				len++;
306fa1
-				if (dst)
306fa1
-					*dst++ = *src;
306fa1
-				src++;
306fa1
-			}
306fa1
+			squote = !squote;
306fa1
 			break;
306fa1
 
306fa1
 		default: