From 2adfbcaeca0c3b565583cbb3d808c1e02ac8bd6d Mon Sep 17 00:00:00 2001 From: liukangcc Date: Wed, 15 Sep 2021 14:16:38 +0800 Subject: [PATCH] [update] enable asctime_r function parameter legal. --- components/libc/compilers/common/time.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 50f6d4c71e..efcfe4dec0 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -239,6 +239,9 @@ RTM_EXPORT(mktime); char* asctime_r(const struct tm *t, char *buf) { + RT_ASSERT(rt_strlen(days) > (t->tm_wday << 2)); + RT_ASSERT(rt_strlen(months) > (t->tm_mon << 2)); + /* "Wed Jun 30 21:49:08 1993\n" */ *(int*) buf = *(int*) (days + (t->tm_wday << 2)); *(int*) (buf + 4) = *(int*) (months + (t->tm_mon << 2));