]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG: fix httplog trailing LF
authorWilly Tarreau <w@1wt.eu>
Fri, 24 Feb 2012 10:46:54 +0000 (11:46 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Feb 2012 10:48:42 +0000 (11:48 +0100)
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
src/proto_http.c

index 17dc28168b9cdcef6cb265d321834ad4088a5590..0d13329356a96a7c058d0213ccf9a4c0f0e87c0f 100644 (file)
--- 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)
 {
index dd40f941acbab5112475b921e76f6402513b8221..cfbebd9f73e77476490d0ec3ca29c4e82587e6f5 100644 (file)
@@ -1241,7 +1241,7 @@ out:
        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;
 
 }