libc: stream adds length check

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2023-03-13 22:42:00 +08:00 committed by Petro Karashchenko
parent 1c9c6e94f0
commit ca290e85ea
1 changed files with 5 additions and 0 deletions

View File

@ -200,6 +200,11 @@ static int syslogstream_puts(FAR struct lib_outstream_s *this,
int ret = 0;
DEBUGASSERT(stream != NULL);
if (len <= 0)
{
return 0;
}
stream->last_ch = ((FAR const char *)buff)[len -1];
#ifdef CONFIG_SYSLOG_BUFFER