Blame SOURCES/autofs-5.1.7-use-sprintf-when-constructing-hosts-mapent.patch

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