From 53bf6af3f9648837c961ba6019f1c318652a6d1c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 24 Feb 2012 11:46:54 +0100 Subject: [PATCH] BUG: fix httplog trailing LF commit a1cc3811 introduced an undesirable \0\n ending on HTTP log messages. This is because of an extra character count passed to __send_log() which causes the LF to be appended past the \0. Some syslog daemons thus log an extra empty line. The fix is obvious. Fix the function comments to remind what they expect on their input. This is past 1.5-dev7 regression so there's no backport needed. --- src/log.c | 3 ++- src/proto_http.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/log.c b/src/log.c index 17dc28168b..0d13329356 100644 --- a/src/log.c +++ b/src/log.c @@ -519,7 +519,7 @@ char *hdr_log(char *dst) /* * This function adds a header to the message and sends the syslog message - * using a printf format string + * using a printf format string. It expects an LF-terminated message. */ void send_log(struct proxy *p, int level, const char *format, ...) { @@ -546,6 +546,7 @@ void send_log(struct proxy *p, int level, const char *format, ...) /* * This function sends a syslog message. * It doesn't care about errors nor does it report them. + * It overrides the last byte (message[size-1]) with an LF character. */ void __send_log(struct proxy *p, int level, char *message, size_t size) { diff --git a/src/proto_http.c b/src/proto_http.c index dd40f941ac..cfbebd9f73 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -1241,7 +1241,7 @@ void http_sess_log(struct session *s) if (tmplog == NULL) // if previous error tmplog = logline + MAX_SYSLOG_LEN - 1; - __send_log(prx_log, level, logline, tmplog - logline + 2); + __send_log(prx_log, level, logline, tmplog - logline + 1); s->logs.logwait = 0; }