MDEV-27297 wsrep error log messages drop last character

vsnprintf takes the space need for trailing '\0' in consideration, and copies only n-1 characters to destination buffer.
With the old code, only sizeof(buf)-2 characters were copied, this caused that last character of message could be lost.

Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
This commit is contained in:
sjaakola 2021-12-20 12:07:20 +02:00 committed by Jan Lindström
parent 49791cbc6f
commit 61a66d81b2

View file

@ -288,7 +288,7 @@ void WSREP_LOG(void (*fun)(const char* fmt, ...), const char* fmt, ...)
char msg[128] = {'\0'};
va_list arglist;
va_start(arglist, fmt);
int n= vsnprintf(msg, sizeof(msg) - 1, fmt, arglist);
int n= vsnprintf(msg, sizeof(msg), fmt, arglist);
va_end(arglist);
if (n < 0)
{