summaryrefslogtreecommitdiff
path: root/components/libc/compilers
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-03-15 11:29:42 +0800
committerMeco Man <[email protected]>2021-03-15 11:29:42 +0800
commitcc1277d491979d01cd47072f2ceb099636ca2254 (patch)
treef4559cc3cd70f250f96852b54f1f954af52172b1 /components/libc/compilers
parentc3ffe18688a3696a486855ae98002714546bd836 (diff)
[libc][time] 修复没有末尾\0的bug
Diffstat (limited to 'components/libc/compilers')
-rw-r--r--components/libc/compilers/common/time.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index ed72cc1f3f..3ffc6381fc 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -16,6 +16,7 @@
* 2012-12-08 Bernard <clock_time.c> fix the issue of _timevalue.tv_usec initialization,
* which found by Rob <[email protected]>
* 2021-02-12 Meco Man move all of the functions located in <clock_time.c> to this file
+ * 2021-03-15 Meco Man fixed bug: https://club.rt-thread.org/ask/question/423650.html
*/
#include <sys/time.h>
@@ -152,13 +153,14 @@ char* asctime_r(const struct tm *t, char *buf)
num2str(buf + 20, (t->tm_year + 1900) / 100);
num2str(buf + 22, (t->tm_year + 1900) % 100);
buf[24] = '\n';
+ buf[25] = '\0';
return buf;
}
RTM_EXPORT(asctime_r);
char* asctime(const struct tm *timeptr)
{
- static char buf[25];
+ static char buf[26];
return asctime_r(timeptr, buf);
}
RTM_EXPORT(asctime);