mirror of
https://github.com/apache/nuttx.git
synced 2026-10-11 08:10:21 +00:00
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
1 changed files with 6 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue