summaryrefslogtreecommitdiff
path: root/include/haproxy/errors.h
diff options
context:
space:
mode:
authorAmaury Denoyelle <adenoyelle@haproxy.com>2021-06-07 19:24:10 +0200
committerAmaury Denoyelle <adenoyelle@haproxy.com>2021-06-08 11:40:44 +0200
commit846830e47d9b8130e353c59f6fdea09c26b64d81 (patch)
treeb47727028c74fec947cf8a6fc85b6d1a5ccdd9cd /include/haproxy/errors.h
parentfc0cceb08a5e11a5e767e3a1d4d44901c454a850 (diff)
downloadhaproxy-846830e47d9b8130e353c59f6fdea09c26b64d81.tar.gz
BUG: errors: remove printf positional args for user messages context
Change the algorithm for the generation of the user messages context prefix. Remove the dubious API relying on optional printf positional arguments. This may be non portable, and in fact the CI glibc crashes with the following error when some arguments are not present in the format string : "invalid %N$ use detected". Now, a fixed buffer attached to the context instance is allocated once for the program lifetime. Then call repeatedly snprintf with the optional arguments of context if present to build the context string. The buffer is deallocated via a per-thread free handler. This does not need to be backported.
Diffstat (limited to 'include/haproxy/errors.h')
-rw-r--r--include/haproxy/errors.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/haproxy/errors.h b/include/haproxy/errors.h
index 6dd60f1e1..a6c117714 100644
--- a/include/haproxy/errors.h
+++ b/include/haproxy/errors.h
@@ -25,6 +25,8 @@
#include <stdarg.h>
#include <stdio.h>
+#include <haproxy/buf-t.h>
+
/* These flags may be used in various functions which are called from within
* loops (eg: to start all listeners from all proxies). They provide enough
* information to let the caller decide what to do. ERR_WARN and ERR_ALERT
@@ -67,6 +69,8 @@ const char *usermsgs_str(void);
/************ Error reporting functions ***********/
struct usermsgs_ctx {
+ struct buffer str;
+
const char *prefix; /* prefix of every output */
const char *file; /* related filename for config parsing */
int line; /* related line number for config parsing */