BUG/MINOR: logs: prevent double line returns in some events.
authorEmeric Brun <ebrun@haproxy.com>
Tue, 12 May 2020 17:33:15 +0000 (19:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 May 2020 06:43:10 +0000 (08:43 +0200)
commitd2fc4f65dbef68136c557871f4e09a498724f7c4
tree943ffd822a905f1ae3445d61dc2397509881164d
parentc2a67711819c7eedc7f4631aa340f04b56083e18
BUG/MINOR: logs: prevent double line returns in some events.

Historically some messages used to already contain the trailing LF but
not all, and __do_send_log adds a new one in needed cases. It also does
trim a trailing LF in certain cases while computing the max message
length, as a result of subtracting 1 to the available room in the
destination buffer. But the way it's done is wrong since some messages
still contain it.

So the code was fixed to always trim the trailing LF from messages if
present, and then only subtract 1 from the destination buffer room
instead of the size..

Note: new sink API is not designed to receive a trailing LF on
event messages

This could be backported to relevant stable versions with particular
care since the logic of the code changed a bit since 1.6 and there
may be other locations that need to be adjusted.

(cherry picked from commit 9e8ea0ae6f63fe1a8119d99b1218ccc095b390ac)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/log.c