Skip to contentSkip to conversation

Treat multimount entries with duplicate keys as invalid

PATCH New Jeff Moyer 1 participant 1 message Apr 29, 2005 Kernel automounter

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 Treat multimount entries with duplicate keys as invalid

Hi Ian,

Again, from the connectathon automount test suite, this map entry is listed in the invalid bin:

b3          \
        /s1                             segfault.boston.redhat.com:/export/automount/export1 \
        /s1                             segfault.boston.redhat.com:/export/automount/export1

The attached patch checks for duplicate keys, and returns failure from multi_add_list if there is one. The test case passes with this patch.

-Jeff

modules/parse_sun.c renamed from modules/parse_sun.c.orig +18 -0
@@ -697,6 +697,18 @@ static int sun_mount(const char *root, c
 	return rv;
 }
 
+static int key_exists(struct multi_mnt *list, char *path, int pathlen)
+{
+	struct multi_mnt *mmptr = list;
+
+	while (mmptr && pathlen == strlen(mmptr->path)) {
+		if (!strncmp(mmptr->path, path, pathlen))
+			return 1;
+		mmptr = mmptr->next;
+	}
+	return 0;
+}
+
 /*
  * Build list of mounts in shortest -> longest order.
  * Pass in list head and return list head.
@@ -727,6 +739,12 @@ struct multi_mnt *multi_add_list(struct 
 		mmptr = mmptr->next;
 	}
 
+	/* if a multimount entry has duplicate keys, it is invalid */
+	if (key_exists(mmptr, path, plen)) {
+		free(new);
+		return NULL;
+	}
+
 	if (old)
 		old->next = new;
 	new->next = mmptr;