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

--- autofs-4.1.4/modules/parse_sun.c.orig       2005-04-29 17:02:07.581358160 
-0400
+++ autofs-4.1.4/modules/parse_sun.c    2005-04-29 17:09:47.947371888 -0400
@@ -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;

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs

Reply via email to