From ca290e85eab4953f0188bd022bf829228c9af5e3 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Mon, 13 Mar 2023 22:42:00 +0800 Subject: [PATCH] libc: stream adds length check Signed-off-by: yinshengkai --- libs/libc/stream/lib_syslogstream.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/libc/stream/lib_syslogstream.c b/libs/libc/stream/lib_syslogstream.c index 9566d7cbbc..21eb8654f9 100644 --- a/libs/libc/stream/lib_syslogstream.c +++ b/libs/libc/stream/lib_syslogstream.c @@ -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