From db88b17c61d769a72fbb0cfd7b95bb258c9eac85 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 30 Jul 2021 10:42:33 +0800 Subject: [PATCH] [TD-5505]:fix timezone string part length issue --- src/os/src/detail/osTime.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index 2a74ef131b..7ae9f58bc4 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -97,11 +97,12 @@ int32_t taosGetTimestampSec() { return (int32_t)time(NULL); } int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t day_light) { /* parse datatime string in with tz */ char *seg = forwardToTimeStringEnd(timestr); + int32_t seg_len = len - (seg - timestr); if (strnchr(timestr, 'T', len, false) != NULL) { return parseTimeWithTz(timestr, time, timePrec, 'T'); } else if (strnchr(timestr, ' ', len, false) != NULL && - (strnchr(seg, 'Z', (int32_t)strlen(seg), false) != NULL || strnchr(seg, 'z', (int32_t)strlen(seg), false) != NULL || - strnchr(seg, '+', (int32_t)strlen(seg), false) != NULL || strnchr(seg, '-', (int32_t)strlen(seg), false) != NULL)) { + (strnchr(seg, 'Z', seg_len, false) != NULL || strnchr(seg, 'z', seg_len, false) != NULL || + strnchr(seg, '+', seg_len, false) != NULL || strnchr(seg, '-', seg_len, false) != NULL)) { return parseTimeWithTz(timestr, time, timePrec, ' '); } else { return (*parseLocaltimeFp[day_light])(timestr, time, timePrec); -- GitLab