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

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