summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2019-06-20 13:50:23 +0300
committerPanu Matilainen <pmatilai@redhat.com>2020-03-26 11:57:58 +0200
commit65707259c847cd95646b0111ff38c36f5a0df8f5 (patch)
tree3758f013fadb1634b161c8aed305a4dacad466a5
parent91756cd35626bc050e79ebad2db2b04dfb887358 (diff)
downloadrpm-65707259c847cd95646b0111ff38c36f5a0df8f5.tar.gz
Fix excessive use of thread local storage (RhBug:1722181)
Commit 6487e873f3169c2bffbd52808b6c749e6c104ff5 introduced a thread local BUFSIZ static buffer for header format error reporting but thread local storage is apparently a rather scarce resource (on some architectures more so than others) and a static buffer is highly excessive use of that resource. Use a thread local pointer to dynamically (re)allocated buffer instead. (cherry picked from commit 0fd720b1f0d3ec733dc1592bb3a7131e899c246b)
-rw-r--r--lib/headerfmt.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/headerfmt.c b/lib/headerfmt.c
index 781a78e41..f4c249a26 100644
--- a/lib/headerfmt.c
+++ b/lib/headerfmt.c
@@ -221,18 +221,18 @@ static char * hsaReserve(headerSprintfArgs hsa, size_t need)
RPM_GNUC_PRINTF(2, 3)
static void hsaError(headerSprintfArgs hsa, const char *fmt, ...)
{
- /* Use thread local static buffer as headerFormat() errmsg arg is const */
- static __thread char errbuf[BUFSIZ];
+ /* Use thread local buffer as headerFormat() errmsg arg is const */
+ static __thread char *errbuf = NULL;
if (fmt == NULL) {
hsa->errmsg = NULL;
} else {
va_list ap;
+ free(errbuf);
va_start(ap, fmt);
- vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
+ rvasprintf(&errbuf, fmt, ap);
va_end(ap);
-
hsa->errmsg = errbuf;
}
}