Blob Blame History Raw
autofs-5.0.3 - handle zero length nis key update

From: Ian Kent <raven@themaw.net>

A zero length key is invalid but so is a single character
non-printable key and it causes the parser to get confused
as well.
---

 modules/lookup_yp.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)


--- autofs-5.0.2.orig/modules/lookup_yp.c
+++ autofs-5.0.2/modules/lookup_yp.c
@@ -19,6 +19,7 @@
 #include <unistd.h>
 #include <time.h>
 #include <signal.h>
+#include <ctype.h>
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -168,6 +169,14 @@ int yp_all_master_callback(int status, c
 	if (status != YP_TRUE)
 		return status;
 
+	/* Ignore zero length and single non-printable char keys */
+	if (ypkeylen == 0 || (ypkeylen == 1 && !isprint(*ypkey))) {
+		warn(logopt, MODPREFIX
+		     "ignoring invalid map entry, zero length or "
+		     "single character non-printable key");
+		return 0;
+	}
+
 	/*
 	 * Ignore keys beginning with '+' as plus map
 	 * inclusion is only valid in file maps.
@@ -263,6 +272,14 @@ int yp_all_callback(int status, char *yp
 	if (status != YP_TRUE)
 		return status;
 
+	/* Ignore zero length and single non-printable char keys */
+	if (ypkeylen == 0 || (ypkeylen == 1 && !isprint(*ypkey))) {
+		warn(logopt, MODPREFIX
+		     "ignoring invalid map entry, zero length or "
+		     "single character non-printable key");
+		return 0;
+	}
+
 	/*
 	 * Ignore keys beginning with '+' as plus map
 	 * inclusion is only valid in file maps.