Sophie

Sophie

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

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

autofs-5.0.1 - fix isspace() wild card substition

From: Ian Kent <raven@themaw.net>

If there are characters that match isspace() (such as \t, \n, etc.) in a
passed map entry key and there is no space in the key these characters
won't be properly preserved, leading to failed or incorrect mounts.

This is caused by an incorrect attempt at optimization, using a check
to see if a space is present in the passed key and only then processing
each character of the key individually, escaping any isspace() characters.
---

 modules/parse_sun.c |   40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)


--- autofs-5.0.1.orig/modules/parse_sun.c
+++ autofs-5.0.1/modules/parse_sun.c
@@ -163,30 +163,24 @@ int expandsunent(const char *src, char *
 		case '&':
 			l = strlen(key);
 			/*
-			 * In order to ensure that any spaces in the key
-			 * re preserved, we need to escape them here.
+			 * In order to ensure that any isspace() characters
+			 * in the key are preserved, we need to escape them
+			 * here.
 			 */
-			if (strchr(key, ' ')) {
-				const 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;
+			const char *keyp = key;
+			while (*keyp) {
+				if (isspace(*keyp)) {
+					if (dst) {
+						*dst++ = '\\';
+						*dst++ = *keyp++;
+					} else
+						keyp++;
+					l++;
+				} else {
+					if (dst)
+						*dst++ = *keyp++;
+					else
+						keyp++;
 				}
 			}
 			len += l;