Blame SOURCES/autofs-5.1.7-fix-mount_fullpath.patch

96dc52
autofs-5.1.7 - fix mount_fullpath()
96dc52
96dc52
From: Ian Kent <raven@themaw.net>
96dc52
96dc52
mount_fullpath() incorrecly fills fullpath with the contents of root
96dc52
when name[0] == '/'. The cases root[last] == '/' and name[0] == '/'
96dc52
need to be handled seperately.
96dc52
96dc52
Signed-off-by: Ian Kent <raven@themaw.net>
96dc52
---
96dc52
 CHANGELOG           |    1 +
96dc52
 lib/mounts.c        |    4 +++-
96dc52
 modules/parse_amd.c |    6 ++++--
96dc52
 3 files changed, 8 insertions(+), 3 deletions(-)
96dc52
96dc52
diff --git a/CHANGELOG b/CHANGELOG
96dc52
index 390028ac..e2fd532c 100644
96dc52
--- a/CHANGELOG
96dc52
+++ b/CHANGELOG
96dc52
@@ -36,6 +36,7 @@
96dc52
 - add tree_mapent_add_node().
96dc52
 - add tree_mapent_delete_offsets().
96dc52
 - add tree_mapent_traverse_subtree().
96dc52
+- fix mount_fullpath().
96dc52
 
96dc52
 25/01/2021 autofs-5.1.7
96dc52
 - make bind mounts propagation slave by default.
96dc52
diff --git a/lib/mounts.c b/lib/mounts.c
96dc52
index fded4c09..497c28c9 100644
96dc52
--- a/lib/mounts.c
96dc52
+++ b/lib/mounts.c
96dc52
@@ -371,8 +371,10 @@ int mount_fullpath(char *fullpath, size_t max_len,
96dc52
 	/* Root offset of multi-mount or direct or offset mount.
96dc52
 	 * Direct or offset mount, name (or root) is absolute path.
96dc52
 	 */
96dc52
-	if (root[last] == '/' || *name == '/')
96dc52
+	if (root[last] == '/')
96dc52
 		len = snprintf(fullpath, max_len, "%s", root);
96dc52
+	else if (*name == '/')
96dc52
+		len = snprintf(fullpath, max_len, "%s", name);
96dc52
 	else
96dc52
 		len = snprintf(fullpath, max_len, "%s/%s", root, name);
96dc52
 
96dc52
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
96dc52
index 5a9079d6..64c1ce63 100644
96dc52
--- a/modules/parse_amd.c
96dc52
+++ b/modules/parse_amd.c
96dc52
@@ -1177,7 +1177,8 @@ static int do_generic_mount(struct autofs_point *ap, const char *name,
96dc52
 		 * the automount filesystem.
96dc52
 		 */
96dc52
 		if (!is_mounted(entry->fs, MNTS_REAL)) {
96dc52
-			ret = do_mount(ap, entry->fs, "/", 1,
96dc52
+			ret = do_mount(ap, entry->fs,
96dc52
+				       entry->fs, strlen(entry->fs),
96dc52
 				       target, entry->type, opts);
96dc52
 			if (ret)
96dc52
 				goto out;
96dc52
@@ -1227,7 +1228,8 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name,
96dc52
 					     mount_nfs->context);
96dc52
 	} else {
96dc52
 		if (!is_mounted(entry->fs, MNTS_REAL)) {
96dc52
-			ret = mount_nfs->mount_mount(ap, entry->fs, "/", 1,
96dc52
+			ret = mount_nfs->mount_mount(ap, entry->fs,
96dc52
+						entry->fs, strlen(entry->fs),
96dc52
 						target, entry->type, opts,
96dc52
 						mount_nfs->context);
96dc52
 			if (ret)