BUG/MEDIUM: bad length in log_format and __send_log

__send_log(): the size of the buffer sent is wrong when the facility
is lower than 3 digits.

logformat_write_string(): computation of size is wrong

Note: this was introduced after 1.5-dev7, no backport needed.
This commit is contained in:
William Lallemand 2012-03-19 16:15:12 +01:00 committed by Willy Tarreau
parent b1a2faf7c9
commit bfb099c3b3

View File

@ -506,7 +506,7 @@ char *logformat_write_string(char *dst, char *src, size_t size, struct logformat
return NULL;
}
dst += strlcpy2(dst, src, size);
size -= orig - dst + 1;
size -= dst - orig + 1;
if (size > 1) {
*(dst++) = '"';
*dst = '\0';
@ -672,7 +672,7 @@ void __send_log(struct proxy *p, int level, char *message, size_t size)
} while (fac_level && log_ptr > dataptr);
*log_ptr = '<';
sent = sendto(*plogfd, log_ptr, size,
sent = sendto(*plogfd, log_ptr, size + log_ptr - dataptr,
MSG_DONTWAIT | MSG_NOSIGNAL,
(struct sockaddr *)&logsrv->addr, get_addr_len(&logsrv->addr));
if (sent < 0) {