autofs/autofs-5.1.7-pass-root-length-to-mount_fullpath.patch
DistroBaker a5adb69dac Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/autofs.git#25aaf0b69441b4e7370a195cbf1c7988d0abef3d
2021-03-26 02:05:45 +00:00

172 lines
5.9 KiB
Diff

autofs-5.1.7 - pass root length to mount_fullpath()
From: Ian Kent <raven@themaw.net>
The length of root may already be known, add a parameter to allow
passing it to mount_fullpath() so a strlen() call can be avoided.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
include/mounts.h | 2 +-
lib/mounts.c | 11 +++++++----
modules/mount_bind.c | 2 +-
modules/mount_changer.c | 2 +-
modules/mount_ext2.c | 2 +-
modules/mount_generic.c | 2 +-
modules/mount_nfs.c | 2 +-
modules/parse_sun.c | 4 ++--
9 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8494f0dc..1c9e2a2d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -44,6 +44,7 @@
- remove obsolete functions.
- remove redundant local var from sun_mount().
- use mount_fullpath() in one spot in parse_mount().
+- pass root length to mount_fullpath().
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
diff --git a/include/mounts.h b/include/mounts.h
index ec895e1c..d7980976 100644
--- a/include/mounts.h
+++ b/include/mounts.h
@@ -131,7 +131,7 @@ int check_nfs_mount_version(struct nfs_mount_vers *, struct nfs_mount_vers *);
extern unsigned int nfs_mount_uses_string_options;
int mount_fullpath(char *fullpath, size_t max_len,
- const char *root, const char *name);
+ const char *root, size_t root_len, const char *name);
struct amd_entry;
diff --git a/lib/mounts.c b/lib/mounts.c
index c120d2a8..6b8e4c92 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -362,11 +362,14 @@ int check_nfs_mount_version(struct nfs_mount_vers *vers,
#endif
int mount_fullpath(char *fullpath, size_t max_len,
- const char *root, const char *name)
+ const char *root, size_t root_len, const char *name)
{
int last, len;
- last = strlen(root) - 1;
+ if (root_len)
+ last = root_len - 1;
+ else
+ last = strlen(root) - 1;
/* Root offset of multi-mount or direct or offset mount.
* Direct or offset mount, name (or root) is absolute path.
@@ -1685,7 +1688,7 @@ void tree_mapent_cleanup_offsets(struct mapent *oe)
else {
char mp[PATH_MAX + 1];
- if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key))
+ if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key))
error(ap->logopt, "mount path is too long");
else
tree_mapent_umount_mount(ap, mp);
@@ -1922,7 +1925,7 @@ int tree_mapent_umount_offsets(struct mapent *oe, int nonstrict)
* one of these keys is the root of a multi-mount the mount
* path must be constructed.
*/
- if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key)) {
+ if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key)) {
error(ap->logopt, "mount path is too long");
return 0;
}
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index c17c6f18..7f64332b 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -122,7 +122,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
}
}
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
if (!len) {
error(ap->logopt,
MODPREFIX "mount point path too long");
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
index d02b5f45..8adb9f9a 100644
--- a/modules/mount_changer.c
+++ b/modules/mount_changer.c
@@ -59,7 +59,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
fstype = "iso9660";
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
if (!len) {
error(ap->logopt,
MODPREFIX "mount point path too long");
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index 53e6ee10..f4002e58 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -55,7 +55,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
if (defaults_get_mount_verbose())
mountlog = &log_info;
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
if (!len) {
error(ap->logopt,
MODPREFIX "mount point path too long");
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
index c9deb7ae..8cd0f4ab 100644
--- a/modules/mount_generic.c
+++ b/modules/mount_generic.c
@@ -54,7 +54,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
if (defaults_get_mount_verbose())
mountlog = &log_info;
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
if (!len) {
error(ap->logopt,
MODPREFIX "mount point path too long");
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index c70210f4..0314a78f 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -213,7 +213,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
}
/* Construct mount point directory */
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
if (!len) {
error(ap->logopt,
MODPREFIX "mount point path too long");
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index d3fc6c7f..b1c2611c 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -1089,7 +1089,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
struct mapent *ro;
size_t len;
- len = mount_fullpath(key, PATH_MAX, ap->path, me->key);
+ len = mount_fullpath(key, PATH_MAX, ap->path, ap->len, me->key);
if (!len) {
warn(ap->logopt, "path loo long");
return 1;
@@ -1359,7 +1359,7 @@ dont_expand:
time_t age;
int l;
- m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, name);
+ m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, ap->len, name);
if (!m_root_len) {
error(ap->logopt,
MODPREFIX "multi-mount root path too long");