Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 198

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

--- autofs-5.0.1/modules/parse_sun.c.trailing-whitespace	2007-05-04 11:49:16.000000000 +0800
+++ autofs-5.0.1/modules/parse_sun.c	2007-05-04 11:49:36.000000000 +0800
@@ -135,9 +135,32 @@
 		switch (ch) {
 		case '&':
 			l = strlen(key);
-			if (dst) {
-				strcpy(dst, key);
-				dst += l;
+			/*
+			 * In order to ensure that any spaces in the key
+			 * re preserved, we need to escape them here.
+			 */
+			if (strchr(key, ' ')) {
+				char *keyp = key;
+				while (*keyp) {
+					if (isspace(*keyp)) {
+						if (dst) {
+							*dst++ = '\\';
+							*dst++ = *keyp++;
+						} else
+							keyp++;
+						l++;
+					} else {
+						if (dst)
+							*dst++ = *keyp++;
+						else
+							keyp++;
+					}
+				}
+			} else {
+				if (dst) {
+					strcpy(dst, key);
+					dst += l;
+				}
 			}
 			len += l;
 			break;
--- autofs-5.0.1/lib/parse_subs.c.trailing-whitespace	2007-05-04 11:49:16.000000000 +0800
+++ autofs-5.0.1/lib/parse_subs.c	2007-05-04 11:49:36.000000000 +0800
@@ -145,10 +145,22 @@
 	const char *scp;
 	int len = origlen;
 	int quote = 0, dquote = 0;
+	int i, j;
 
 	if (ret == NULL)
 		return NULL;
 
+	/* first thing to do is strip white space from the end */
+	i = len - 1;
+	while (isspace(str[i])) {
+		/* of course, we have to keep escaped white-space */
+		j = i - 1;
+		if (j > 0 && (str[j] == '\\' || str[j] == '"'))
+			break;
+		i--;
+		len--;
+	}
+
 	for (scp = str; len > 0 && *scp; scp++, len--) {
 		if (!quote) {
 			if (*scp == '"') {