From df97447088ec931320fca6370cc360cb19a82a59 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 28 Dec 2012 02:44:01 +0100 Subject: [PATCH] BUG/MINOR: http: http-request add-header emits a corrupted header David BERARD reported that http-request add-header passes a \0 along with the header field, which of course is not appropriate. This is caused by build_logline() which sometimes returns the size with the trailing zero and sometimes can return an empty string. Let's fix this function instead of fixing the places where it's used. --- src/log.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/log.c b/src/log.c index c07b62d6b5..b733811d3f 100644 --- a/src/log.c +++ b/src/log.c @@ -844,7 +844,11 @@ const char sess_set_cookie[8] = "NPDIRU67"; /* No set-cookie, Set-cookie found a } while(0) - +/* Builds a log line in based on , and stops before reaching + * characters. Returns the size of the output string in characters, + * not counting the trailing zero which is always added if the resulting size + * is not zero. + */ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *list_format) { struct proxy *fe = s->fe; @@ -1474,8 +1478,7 @@ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *lis out: /* *tmplog is a unused character */ *tmplog = '\0'; - - return tmplog - dst + 1; + return tmplog - dst; } @@ -1507,7 +1510,7 @@ void sess_log(struct session *s) size = tmplog - logline; size += build_logline(s, tmplog, sizeof(logline) - size, &s->fe->logformat); if (size > 0) { - __send_log(s->fe, level, logline, size); + __send_log(s->fe, level, logline, size + 1); s->logs.logwait = 0; } } -- 2.47.3