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