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.
diff --git a/src/log.c b/src/log.c
index 5d67294..622f7f9 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1571,6 +1571,10 @@
 
 	dataptr = message;
 
+	/* historically some messages used to already contain the trailing LF */
+	if (size && (dataptr[size-1] == '\n'))
+		size--;
+
 	if (logsrv->type == LOG_TARGET_FD) {
 		/* the socket's address is a file descriptor */
 		plogfd = (int *)&((struct sockaddr_in *)&logsrv->addr)->sin_addr.s_addr;
@@ -1625,7 +1629,7 @@
 		hdr_ptr = hdr;
 		hdr_max = 3;
 		maxlen = logsrv->maxlen - hdr_max;
-		max = MIN(size, maxlen) - 1;
+		max = MIN(size, maxlen - 1);
 		goto send;
 
 	case LOG_FORMAT_RAW:
@@ -1633,7 +1637,7 @@
 		hdr_ptr = hdr = "";
 		hdr_max = 0;
 		maxlen = logsrv->maxlen;
-		max = MIN(size, maxlen) - 1;
+		max = MIN(size, maxlen - 1);
 		goto send;
 
 	default:
@@ -1717,7 +1721,7 @@
 		goto send;
 	}
 
-	max = MIN(size, maxlen - sd_max) - 1;
+	max = MIN(size, maxlen - sd_max - 1);
 send:
 	if (logsrv->addr.ss_family == AF_UNSPEC) {
 		/* the target is a file descriptor or a ring buffer */