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:
parent
4ac7945676
commit
1692aa7894
@ -56,6 +56,11 @@ static int syslogstream_flush(FAR struct lib_syslogstream_s *stream)
|
||||
|
||||
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 */
|
||||
|
||||
do
|
||||
@ -100,7 +105,7 @@ static void syslogstream_addchar(FAR struct lib_syslogstream_s *stream,
|
||||
|
||||
/* Is the buffer full? */
|
||||
|
||||
if (iob->io_len >= CONFIG_IOB_BUFSIZE)
|
||||
if (iob->io_len >= CONFIG_IOB_BUFSIZE - 1)
|
||||
{
|
||||
/* Yes.. then flush the buffer */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user