- update patch "eliminate-some-more-alloca-usage" for bug 1984808.

This commit is contained in:
Ian Kent 2021-08-02 08:11:51 +08:00
parent cb8d3f7596
commit d11ac98e35

View File

@ -6,19 +6,28 @@ Quite a bit of the alloca(3) usage has been eliminated over time.
Use malloc(3) for some more cases that might need to allocate a largish
amount of storage.
Signed-off-by: Ian Kent <raven@themaw.net>
---
autofs-5.1.7 - eliminate some more alloca usage
From: Ian Kent <raven@themaw.net>
Quite a bit of the alloca(3) usage has been eliminated over time.
Use malloc(3) for some more cases that might need to allocate a largish
amount of storage.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/lookup_program.c | 11 ++++++++++-
modules/lookup_yp.c | 22 +++++++++++++++++++---
modules/parse_sun.c | 13 +++++++++++--
modules/replicated.c | 15 ++++-----------
5 files changed, 45 insertions(+), 17 deletions(-)
modules/parse_sun.c | 18 ++++++++++++++----
modules/replicated.c | 19 ++++++-------------
5 files changed, 50 insertions(+), 21 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8d050552..2b7cfaa0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -79,6 +79,7 @@
- add missing description of null map option.
- fix nonstrict offset mount fail handling.
@ -27,11 +36,9 @@ index 8d050552..2b7cfaa0 100644
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
diff --git a/modules/lookup_program.c b/modules/lookup_program.c
index 6cab52c8..028580e5 100644
--- a/modules/lookup_program.c
+++ b/modules/lookup_program.c
@@ -636,7 +636,14 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
--- autofs-5.1.7.orig/modules/lookup_program.c
+++ autofs-5.1.7/modules/lookup_program.c
@@ -636,7 +636,14 @@ int lookup_mount(struct autofs_point *ap
char *ent = NULL;
if (me->mapent) {
@ -47,7 +54,7 @@ index 6cab52c8..028580e5 100644
strcpy(ent, me->mapent);
}
cache_unlock(mc);
@@ -644,6 +651,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
@@ -644,6 +651,8 @@ int lookup_mount(struct autofs_point *ap
ap->entry->current = source;
ret = ctxt->parse->parse_mount(ap, name,
name_len, ent, ctxt->parse->context);
@ -56,11 +63,9 @@ index 6cab52c8..028580e5 100644
goto out_free;
} else {
if (IS_MM(me) && !IS_MM_ROOT(me)) {
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
index 8bccb72f..d2a4b5a5 100644
--- a/modules/lookup_yp.c
+++ b/modules/lookup_yp.c
@@ -254,7 +254,7 @@ int yp_all_master_callback(int status, char *ypkey, int ypkeylen,
--- autofs-5.1.7.orig/modules/lookup_yp.c
+++ autofs-5.1.7/modules/lookup_yp.c
@@ -254,7 +254,7 @@ int yp_all_master_callback(int status, c
len = ypkeylen + 1 + vallen + 2;
@ -69,7 +74,7 @@ index 8bccb72f..d2a4b5a5 100644
if (!buffer) {
error(logopt, MODPREFIX "could not malloc parse buffer");
return 0;
@@ -267,6 +267,8 @@ int yp_all_master_callback(int status, char *ypkey, int ypkeylen,
@@ -267,6 +267,8 @@ int yp_all_master_callback(int status, c
master_parse_entry(buffer, timeout, logging, age);
@ -78,7 +83,7 @@ index 8bccb72f..d2a4b5a5 100644
return 0;
}
@@ -368,7 +370,12 @@ int yp_all_callback(int status, char *ypkey, int ypkeylen,
@@ -368,7 +370,12 @@ int yp_all_callback(int status, char *yp
return 0;
}
@ -92,7 +97,7 @@ index 8bccb72f..d2a4b5a5 100644
strncpy(mapent, val, vallen);
*(mapent + vallen) = '\0';
@@ -377,6 +384,7 @@ int yp_all_callback(int status, char *ypkey, int ypkeylen,
@@ -377,6 +384,7 @@ int yp_all_callback(int status, char *yp
cache_unlock(mc);
free(key);
@ -100,7 +105,7 @@ index 8bccb72f..d2a4b5a5 100644
if (ret == CHE_FAIL)
return -1;
@@ -904,7 +912,14 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
@@ -904,7 +912,14 @@ int lookup_mount(struct autofs_point *ap
}
if (me && (me->source == source || *me->key == '/')) {
mapent_len = strlen(me->mapent);
@ -116,7 +121,7 @@ index 8bccb72f..d2a4b5a5 100644
strcpy(mapent, me->mapent);
}
}
@@ -929,6 +944,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
@@ -929,6 +944,7 @@ int lookup_mount(struct autofs_point *ap
ret = ctxt->parse->parse_mount(ap, key, key_len,
mapent, ctxt->parse->context);
@ -124,11 +129,9 @@ index 8bccb72f..d2a4b5a5 100644
if (ret) {
/* Don't update negative cache when re-connecting */
if (ap->flags & MOUNT_FLAG_REMOUNT)
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index 9190165d..c65bfce0 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -668,9 +668,16 @@ static int sun_mount(struct autofs_point *ap, const char *root,
--- autofs-5.1.7.orig/modules/parse_sun.c
+++ autofs-5.1.7/modules/parse_sun.c
@@ -668,9 +668,16 @@ static int sun_mount(struct autofs_point
}
}
@ -146,15 +149,21 @@ index 9190165d..c65bfce0 100644
memcpy(what, loc, loclen);
what[loclen] = '\0';
@@ -709,7 +716,6 @@ static int sun_mount(struct autofs_point *ap, const char *root,
if (!loclen)
@@ -706,10 +713,10 @@ static int sun_mount(struct autofs_point
rv = mount_nfs->mount_mount(ap, root, name, namelen,
what, fstype, options, mount_nfs->context);
} else {
- if (!loclen)
+ if (!loclen) {
+ free(what);
what = NULL;
else {
- else {
- what = alloca(loclen + 1);
+ } else {
if (*loc == ':') {
loclen--;
memcpy(what, loc + 1, loclen);
@@ -728,6 +734,9 @@ static int sun_mount(struct autofs_point *ap, const char *root,
@@ -728,6 +735,9 @@ static int sun_mount(struct autofs_point
/* Generic mount routine */
rv = do_mount(ap, root, name, namelen, what, fstype, options);
}
@ -164,12 +173,14 @@ index 9190165d..c65bfce0 100644
pthread_setcancelstate(cur_state, NULL);
if (nonstrict && rv)
diff --git a/modules/replicated.c b/modules/replicated.c
index 03d4ba1e..e68a3cc6 100644
--- a/modules/replicated.c
+++ b/modules/replicated.c
@@ -1044,22 +1044,15 @@ done:
static int add_path(struct host *hosts, const char *path, int len)
--- autofs-5.1.7.orig/modules/replicated.c
+++ autofs-5.1.7/modules/replicated.c
@@ -1041,25 +1041,18 @@ done:
return ret;
}
-static int add_path(struct host *hosts, const char *path, int len)
+static int add_path(struct host *hosts, const char *path)
{
struct host *this;
- char *tmp, *tmp2;
@ -195,3 +206,12 @@ index 03d4ba1e..e68a3cc6 100644
}
this = this->next;
}
@@ -1188,7 +1181,7 @@ int parse_location(unsigned logopt, stru
}
}
- if (!add_path(*hosts, path, strlen(path))) {
+ if (!add_path(*hosts, path)) {
free_host_list(hosts);
free(str);
return 0;