autofs-5.0.5 - fix isspace() wild card substition From: Ian Kent 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. --- CHANGELOG | 1 + modules/parse_sun.c | 40 +++++++++++++++++----------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c98204d..72590f7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -56,6 +56,7 @@ - fix add simple bind auth. - add option to dump configured automount maps. - use weight only for server selection. +- fix isspace() wild card substition. 03/09/2009 autofs-5.0.5 ----------------------- diff --git a/modules/parse_sun.c b/modules/parse_sun.c index 4bddcc9..3242e3b 100644 --- a/modules/parse_sun.c +++ b/modules/parse_sun.c @@ -161,30 +161,24 @@ int expandsunent(const char *src, char *dst, const char *key, 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;