drivers/syslog: Ensure the buffer zero terminate

This patch fix the regression by:
commit 174b240325
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Fri Sep 17 11:56:21 2021 +0800

    drivers/syslog: Call up_puts in syslog_default_write instad up_putc

    since some drivers(e.g. semihosting) have more fast implementation.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-09-21 18:21:41 +08:00 committed by Alan Carvalho de Assis
parent 4ac7945676
commit 1692aa7894

View File

@ -56,6 +56,11 @@ static int syslogstream_flush(FAR struct lib_syslogstream_s *stream)
if (iob != NULL && iob->io_len > 0) if (iob != NULL && iob->io_len > 0)
{ {
/* Ensure the buffer is zero terminated */
DEBUGASSERT(iob->io_len < CONFIG_IOB_BUFSIZE);
iob->io_data[iob->io_len] = '\0';
/* Yes write the buffered data */ /* Yes write the buffered data */
do do
@ -100,7 +105,7 @@ static void syslogstream_addchar(FAR struct lib_syslogstream_s *stream,
/* Is the buffer full? */ /* Is the buffer full? */
if (iob->io_len >= CONFIG_IOB_BUFSIZE) if (iob->io_len >= CONFIG_IOB_BUFSIZE - 1)
{ {
/* Yes.. then flush the buffer */ /* Yes.. then flush the buffer */