Sophie

Sophie

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

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

autofs-5.0.1 - fix wildcard map entry match

From: Ian Kent <raven@themaw.net>

In some cases we can get a key string that includes a '*' at the start.
This causes an incorrect comparison in the cache library routines and can
lead to a segmentation fault.

This patch enures that the key length is also considered when checking the
wildcard key entry.
---

 daemon/lookup.c |    4 ++--
 lib/cache.c     |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)


--- autofs-5.0.1.orig/daemon/lookup.c
+++ autofs-5.0.1/daemon/lookup.c
@@ -592,7 +592,7 @@ int lookup_ghost(struct autofs_point *ap
 		cache_readlock(mc);
 		me = cache_enumerate(mc, NULL);
 		while (me) {
-			if (*me->key == '*')
+			if (!strcmp(me->key, "*"))
 				goto next;
 
 			if (*me->key == '/') {
@@ -1026,7 +1026,7 @@ void lookup_prune_one_cache(struct autof
 
 		key = strdup(me->key);
 		me = cache_enumerate(mc, me);
-		if (!key || *key == '*') {
+		if (!key || !strcmp(key, "*")) {
 			if (key)
 				free(key);
 			continue;
--- autofs-5.0.1.orig/lib/cache.c
+++ autofs-5.0.1/lib/cache.c
@@ -744,7 +744,7 @@ int cache_update(struct mapent_cache *mc
 	me = cache_lookup(mc, key);
 	while (me && me->source != ms)
 		me = cache_lookup_key_next(me);
-	if (!me || (*me->key == '*' && *key != '*')) {
+	if (!me || (!strcmp(me->key, "*") && strcmp(key, "*"))) {
 		ret = cache_add(mc, ms, key, mapent, age);
 		if (!ret) {
 			debug(logopt, "failed for %s", key);