autofs-5.1.8 - fail on empty replicated host name

From: Ian Kent <raven@themaw.net>

If a mount location host (or hosts) has an empty host name it has to be
a mistake so fail the automount request.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG           |    1 +
 modules/parse_sun.c |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 0688304e..b5c259bb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -52,6 +52,7 @@
 - fix additional tsv invalid access.
 - fix use_ignore_mount_option description.
 - include addtional log info for mounts.
+- fail on empty replicated host name.
 
 19/10/2021 autofs-5.1.8
 - add xdr_exports().
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index 759e580b..74ac4712 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -935,6 +935,12 @@ static int validate_location(unsigned int logopt, char *loc)
 	if (*ptr == ':')
 		return 1;
 
+	/* Fail on replicated entry with empty first host name */
+	if (*ptr == ',') {
+		error(logopt, "missing first host name in location %s", loc);
+		return 0;
+	}
+
 	/*
 	 * If a ':/' is present now it must be a host name, except
 	 * for those special file systems like sshfs which use "#"
@@ -971,6 +977,18 @@ static int validate_location(unsigned int logopt, char *loc)
 				      "found in location %s", *ptr, loc);
 				return 0;
 			}
+
+			/* Fail on replicated entry with empty host name */
+			if (*ptr == ',') {
+				char next = *(ptr + 1);
+
+				if (next == ',' || next == ':') {
+					error(logopt,
+					      "missing host name in location %s", loc);
+					return 0;
+				}
+			}
+
 			ptr++;
 		}