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

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