Blob Blame History Raw
autofs-5.0.5 - mapent becomes negative during lookup

From: Ian Kent <raven@themaw.net>

During a mount request it is possible for a mapent to become negative
between the time it is checked on entry and when we fetch the mount
location information. This is because we drop the cache lock after
the initial check and take it back again before getting the location
information.
---

 CHANGELOG                |    1 +
 modules/lookup_file.c    |    2 +-
 modules/lookup_ldap.c    |    2 +-
 modules/lookup_nisplus.c |    2 +-
 modules/lookup_yp.c      |    2 +-
 5 files changed, 5 insertions(+), 4 deletions(-)


--- autofs-5.0.5.orig/CHANGELOG
+++ autofs-5.0.5/CHANGELOG
@@ -40,6 +40,7 @@
 - dont check null cache on expire.
 - fix null cache race.
 - fix cache_init() on source re-read.
+- fix mapent becomes negative during lookup.
 
 03/09/2009 autofs-5.0.5
 -----------------------
--- autofs-5.0.5.orig/modules/lookup_file.c
+++ autofs-5.0.5/modules/lookup_file.c
@@ -1047,7 +1047,7 @@ do_cache_lookup:
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && (me->source == source || *me->key == '/')) {
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
 		pthread_cleanup_push(cache_lock_cleanup, mc);
 		strcpy(mapent_buf, me->mapent);
 		mapent = mapent_buf;
--- autofs-5.0.5.orig/modules/lookup_ldap.c
+++ autofs-5.0.5/modules/lookup_ldap.c
@@ -2872,7 +2872,7 @@ int lookup_mount(struct autofs_point *ap
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && (me->source == source || *me->key == '/')) {
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
 		strcpy(mapent_buf, me->mapent);
 		mapent = mapent_buf;
 	}
--- autofs-5.0.5.orig/modules/lookup_nisplus.c
+++ autofs-5.0.5/modules/lookup_nisplus.c
@@ -569,7 +569,7 @@ int lookup_mount(struct autofs_point *ap
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && (me->source == source || *me->key == '/')) {
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
 		mapent_len = strlen(me->mapent);
 		mapent = malloc(mapent_len + 1);
 		strcpy(mapent, me->mapent);
--- autofs-5.0.5.orig/modules/lookup_yp.c
+++ autofs-5.0.5/modules/lookup_yp.c
@@ -670,7 +670,7 @@ int lookup_mount(struct autofs_point *ap
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && (me->source == source || *me->key == '/')) {
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
 		mapent_len = strlen(me->mapent);
 		mapent = alloca(mapent_len + 1);
 		strcpy(mapent, me->mapent);