Skip to content

Commit

Permalink
driver/syslog: reset syslog buffer when syslog buffer include invalid…
Browse files Browse the repository at this point in the history
… data

When the machine is cold started, the psram area where the syslog
buffer is located contains some random values, so it will cause
loss of valid log.

Signed-off-by: dongjiuzhu1 <[email protected]>
  • Loading branch information
Donny9 authored and pkarashchenko committed Sep 7, 2023
1 parent 7115b6a commit bfb0095
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion drivers/syslog/ramlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ static void ramlog_initbuf(void)
{
cur = priv->rl_buffer[i];

if (!isascii(cur))
if (!isprint(cur) && !isspace(cur) && cur != '\0')
{
memset(priv->rl_buffer, 0, priv->rl_bufsize);
is_empty = true;
break;
}
else if (prev && !cur)
Expand Down
5 changes: 3 additions & 2 deletions drivers/syslog/syslog_rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@ void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
{
cur = priv->buffer[i];

if (!isascii(cur))
if (!isprint(cur) && !isspace(cur) && cur != '\0')
{
memset(priv->buffer, 0, size);
memset(buffer, 0, size);
is_empty = true;
break;
}
else if (prev && !cur)
Expand Down

0 comments on commit bfb0095

Please sign in to comment.