1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

logging: ellipsisize logs longer than our line buffer

Currently the line buffer for vsnprintf() is 256, lines longer than that
end abruptly without a CRLF.

Change it to end with "...\n\0" when it truncates the line.

CSP header additions, logged on vhost init, longer than this are going
to become normal...
This commit is contained in:
Andy Green 2018-09-02 07:13:56 +08:00
parent 1665df4642
commit ca33d2f5bf

View file

@ -2066,8 +2066,14 @@ LWS_VISIBLE void _lws_logv(int filter, const char *format, va_list vl)
n = vsnprintf(buf, sizeof(buf) - 1, format, vl);
(void)n;
/* vnsprintf returns what it would have written, even if truncated */
if (n > (int)sizeof(buf) - 1)
n = sizeof(buf) - 1;
if (n > (int)sizeof(buf) - 1) {
n = sizeof(buf) - 5;
buf[n++] = '.';
buf[n++] = '.';
buf[n++] = '.';
buf[n++] = '\n';
buf[n] = '\0';
}
if (n > 0)
buf[n] = '\0';