Blame SOURCES/autofs-5.1.1-fix-map-format-check-in-nss_open_lookup-multi-map-module.patch

4d476f
autofs-5.1.1 - fix map format check in nss_open_lookup() multi map module
4d476f
4d476f
From: Ian Kent <raven@themaw.net>
4d476f
4d476f
The nss_open_lookup() function doesn't properly allow for map format when
4d476f
it's given with the map type.
4d476f
4d476f
Signed-off-by: Ian Kent <raven@themaw.net>
4d476f
---
4d476f
 modules/lookup_multi.c |   16 ++++++++++++----
4d476f
 1 file changed, 12 insertions(+), 4 deletions(-)
4d476f
4d476f
diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
4d476f
index 433b424..f8ebf94 100644
4d476f
--- a/modules/lookup_multi.c
4d476f
+++ b/modules/lookup_multi.c
4d476f
@@ -24,6 +24,8 @@
4d476f
 #include "automount.h"
4d476f
 #include "nsswitch.h"
4d476f
 
4d476f
+#define MAX_MAP_TYPE_STRING	20
4d476f
+
4d476f
 #define MODPREFIX "lookup(multi): "
4d476f
 
4d476f
 struct module_info {
4d476f
@@ -166,11 +168,17 @@ static struct lookup_mod *nss_open_lookup(const char *format, int argc, const ch
4d476f
 	    !strncmp(argv[0], "ldaps", 5) ||
4d476f
 	    !strncmp(argv[0], "ldap", 4) ||
4d476f
 	    !strncmp(argv[0], "sss", 3)) {
4d476f
-		const char *fmt = strchr(argv[0], ',');
4d476f
-		if (fmt)
4d476f
+		char type[MAX_MAP_TYPE_STRING];
4d476f
+		char *fmt;
4d476f
+
4d476f
+		strcpy(type, argv[0]);
4d476f
+		fmt = strchr(type, ',');
4d476f
+		if (!fmt)
4d476f
+			fmt = (char *) format;
4d476f
+		else {
4d476f
+			*fmt = '\0';
4d476f
 			fmt++;
4d476f
-		else
4d476f
-			fmt = format;
4d476f
+		}
4d476f
 		open_lookup(argv[0], MODPREFIX, fmt, argc - 1, argv + 1, &mod);
4d476f
 		return mod;
4d476f
 	}