From f04244848065cced26b65034391e996420fb6d95 Mon Sep 17 00:00:00 2001 From: Emeric Brun Date: Thu, 28 May 2020 14:21:33 +0200 Subject: [PATCH] BUG/MEDIUM: logs: fix trailing zeros on log message. This patch removes all trailing LFs and Zeros from log messages. Previously only the last LF was removed. It's a regression from e8ea0ae6f6 "BUG/MINOR: logs: prevent double line returns in some events." This should fix github issue #654 (cherry picked from commit fa9d780119adc687e58a8b09e55780a0173b4ab4) Signed-off-by: Willy Tarreau --- src/log.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/log.c b/src/log.c index cf5d87e..4ad7147 100644 --- a/src/log.c +++ b/src/log.c @@ -1540,8 +1540,10 @@ static inline void __do_send_log(struct logsrv *logsrv, int nblogger, char *pid_ dataptr = message; - /* historically some messages used to already contain the trailing LF */ - if (size && (dataptr[size-1] == '\n')) + /* historically some messages used to already contain the trailing LF + * or Zero. Let's remove all trailing LF or Zero + */ + while (size && ((dataptr[size-1] == '\n' || (dataptr[size-1] == 0)))) size--; if (logsrv->type == LOG_TARGET_FD) { -- 1.7.10.4