From b2adb9e4ef709068dafbc5d3d75af9e1b6baf77c Mon Sep 17 00:00:00 2001 From: Packit Service Date: Apr 16 2021 22:13:59 +0000 Subject: Apply patch autofs-5.1.7-use-sprintf-when-constructing-hosts-mapent.patch patch_name: autofs-5.1.7-use-sprintf-when-constructing-hosts-mapent.patch present_in_specfile: true --- diff --git a/CHANGELOG b/CHANGELOG index ff3e195..89be201 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ - add xdr_exports(). - remove mount.x and rpcgen dependencies. - dont use realloc in host exports list processing. +- use sprintf() when constructing hosts mapent. xx/xx/2018 autofs-5.1.5 - fix flag file permission. diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c index 4b55a88..f1111e6 100644 --- a/modules/lookup_hosts.c +++ b/modules/lookup_hosts.c @@ -87,10 +87,12 @@ int lookup_read_master(struct master *master, time_t age, void *context) static char *get_exports(struct autofs_point *ap, const char *host) { char buf[MAX_ERR_BUF]; + char entry[PATH_MAX + 1]; char *mapent; struct exportinfo *exp, *this; size_t hostlen = strlen(host); size_t mapent_len; + int len, pos; debug(ap->logopt, MODPREFIX "fetchng export list for %s", host); @@ -114,21 +116,19 @@ static char *get_exports(struct autofs_point *ap, const char *host) } *mapent = 0; + pos = 0; this = exp; - while (this) { - if (!*mapent) - strcpy(mapent, "\""); - else - strcat(mapent, " \""); - strcat(mapent, this->dir); - strcat(mapent, "\""); - - strcat(mapent, " \""); - strcat(mapent, host); - strcat(mapent, ":"); - strcat(mapent, this->dir); - strcat(mapent, "\""); + if (this) { + len = sprintf(mapent, "\"%s\" \"%s:%s\"", + this->dir, host, this->dir); + pos += len; + this = this->next; + } + while (this) { + len = sprintf(mapent + pos, " \"%s\" \"%s:%s\"", + this->dir, host, this->dir); + pos += len; this = this->next; } rpc_exports_free(exp);