|
|
9a499a |
autofs-5.1.7 - use snprintf() when constructing hosts mapent
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Using multiple strcpy() and strcat() functions when constructing the
|
|
|
9a499a |
hosts map offset for each export is much slower than using a single
|
|
|
9a499a |
sprintf() for each.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
modules/lookup_hosts.c | 26 +++++++++++++-------------
|
|
|
9a499a |
2 files changed, 14 insertions(+), 13 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -2,6 +2,7 @@
|
|
|
9a499a |
- add xdr_exports().
|
|
|
9a499a |
- remove mount.x and rpcgen dependencies.
|
|
|
9a499a |
- dont use realloc in host exports list processing.
|
|
|
9a499a |
+- use sprintf() when constructing hosts mapent.
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/lookup_hosts.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/lookup_hosts.c
|
|
|
9a499a |
@@ -87,10 +87,12 @@ int lookup_read_master(struct master *ma
|
|
|
9a499a |
static char *get_exports(struct autofs_point *ap, const char *host)
|
|
|
9a499a |
{
|
|
|
9a499a |
char buf[MAX_ERR_BUF];
|
|
|
9a499a |
+ char entry[PATH_MAX + 1];
|
|
|
9a499a |
char *mapent;
|
|
|
9a499a |
struct exportinfo *exp, *this;
|
|
|
9a499a |
size_t hostlen = strlen(host);
|
|
|
9a499a |
size_t mapent_len;
|
|
|
9a499a |
+ int len, pos;
|
|
|
9a499a |
|
|
|
9a499a |
debug(ap->logopt, MODPREFIX "fetchng export list for %s", host);
|
|
|
9a499a |
|
|
|
9a499a |
@@ -114,21 +116,19 @@ static char *get_exports(struct autofs_p
|
|
|
9a499a |
}
|
|
|
9a499a |
*mapent = 0;
|
|
|
9a499a |
|
|
|
9a499a |
+ pos = 0;
|
|
|
9a499a |
this = exp;
|
|
|
9a499a |
- while (this) {
|
|
|
9a499a |
- if (!*mapent)
|
|
|
9a499a |
- strcpy(mapent, "\"");
|
|
|
9a499a |
- else
|
|
|
9a499a |
- strcat(mapent, " \"");
|
|
|
9a499a |
- strcat(mapent, this->dir);
|
|
|
9a499a |
- strcat(mapent, "\"");
|
|
|
9a499a |
-
|
|
|
9a499a |
- strcat(mapent, " \"");
|
|
|
9a499a |
- strcat(mapent, host);
|
|
|
9a499a |
- strcat(mapent, ":");
|
|
|
9a499a |
- strcat(mapent, this->dir);
|
|
|
9a499a |
- strcat(mapent, "\"");
|
|
|
9a499a |
+ if (this) {
|
|
|
9a499a |
+ len = sprintf(mapent, "\"%s\" \"%s:%s\"",
|
|
|
9a499a |
+ this->dir, host, this->dir);
|
|
|
9a499a |
+ pos += len;
|
|
|
9a499a |
+ this = this->next;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
|
|
|
9a499a |
+ while (this) {
|
|
|
9a499a |
+ len = sprintf(mapent + pos, " \"%s\" \"%s:%s\"",
|
|
|
9a499a |
+ this->dir, host, this->dir);
|
|
|
9a499a |
+ pos += len;
|
|
|
9a499a |
this = this->next;
|
|
|
9a499a |
}
|
|
|
9a499a |
rpc_exports_free(exp);
|