autofs/SOURCES/autofs-5.1.7-use-mount_full...

71 lines
1.9 KiB
Diff

autofs-5.1.7 - use mount_fullpath() in one spot in parse_mount()
From: Ian Kent <raven@themaw.net>
mount_fullpath() is meant to be used for this type of path construction
so use it.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_sun.c | 34 ++++++++--------------------------
2 files changed, 9 insertions(+), 26 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -43,6 +43,7 @@
- switch to use tree implementation for offsets.
- remove obsolete functions.
- remove redundant local var from sun_mount().
+- use mount_fullpath() in one spot in parse_mount().
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/parse_sun.c
+++ autofs-5.1.4/modules/parse_sun.c
@@ -1356,36 +1356,18 @@ dont_expand:
debug(ap->logopt, MODPREFIX "gathered options: %s", options);
if (check_is_multi(p)) {
- char *m_root = NULL;
+ char m_root[PATH_MAX + 1];
int m_root_len;
time_t age;
int l;
- /* If name starts with "/" it's a direct mount */
- if (*name == '/') {
- m_root_len = name_len;
- m_root = alloca(m_root_len + 1);
- if (!m_root) {
- char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
- free(options);
- free(pmapent);
- logerr(MODPREFIX "alloca: %s", estr);
- return 1;
- }
- strcpy(m_root, name);
- } else {
- m_root_len = ap->len + name_len + 1;
- m_root = alloca(m_root_len + 1);
- if (!m_root) {
- char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
- free(options);
- free(pmapent);
- logerr(MODPREFIX "alloca: %s", estr);
- return 1;
- }
- strcpy(m_root, ap->path);
- strcat(m_root, "/");
- strcat(m_root, name);
+ m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, name);
+ if (!m_root_len) {
+ error(ap->logopt,
+ MODPREFIX "multi-mount root path too long");
+ free(options);
+ free(pmapent);
+ return 1;
}
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);