From: Aurelien DARRAGON Date: Mon, 29 Apr 2024 13:31:17 +0000 (+0200) Subject: BUG/MINOR: log/encode: consider global options for key encoding X-Git-Tag: v3.0-dev10~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=949ac95aa6d69d810cd6ed40138f033f5065e305;p=thirdparty%2Fhaproxy.git BUG/MINOR: log/encode: consider global options for key encoding In sess_build_logline(), contrary to what's stated in the comment "only consider global ctx for key encoding", we check for LOG_OPT_ENCODE flag on the current ctx options instead of global ones. Because of this, we could end up doing the wrong thing if the previous node had encoding enabled but it isn't set globally for instance. To fix the issue, let's simply check the presence of the flag on g_options before entering the "key encoding" block. This bug was introduced with 3f7c8387 ("MINOR: log: add +json encoding option"), no backport needed. --- diff --git a/src/log.c b/src/log.c index 2cde788313..31295d2888 100644 --- a/src/log.c +++ b/src/log.c @@ -3635,7 +3635,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t struct sample *key; const struct buffer empty = { }; - if (ctx.options & LOG_OPT_ENCODE) { + if (g_options & LOG_OPT_ENCODE) { /* only consider global ctx for key encoding */ lf_buildctx_prepare(&ctx, g_options, NULL);