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

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