Merge branch 'develop' into hotfix/crash

This commit is contained in:
Shengliang Guan 2020-07-05 23:52:51 +08:00
commit 956e37508a
1 changed files with 9 additions and 10 deletions

View File

@ -160,7 +160,7 @@ static void taosGetSystemTimezone() {
/* load time zone string from /etc/timezone */ /* load time zone string from /etc/timezone */
FILE *f = fopen("/etc/timezone", "r"); FILE *f = fopen("/etc/timezone", "r");
char buf[65] = {0}; char buf[68] = {0};
if (f != NULL) { if (f != NULL) {
int len = fread(buf, 64, 1, f); int len = fread(buf, 64, 1, f);
if(len < 64 && ferror(f)) { if(len < 64 && ferror(f)) {
@ -170,18 +170,17 @@ static void taosGetSystemTimezone() {
} }
fclose(f); fclose(f);
}
char *lineEnd = strstr(buf, "\n"); char *lineEnd = strstr(buf, "\n");
if (lineEnd != NULL) { if (lineEnd != NULL) {
*lineEnd = 0; *lineEnd = 0;
} }
// for CentOS system, /etc/timezone does not exist. Ignore the TZ environment variables // for CentOS system, /etc/timezone does not exist. Ignore the TZ environment variables
if (strlen(buf) > 0) { if (strlen(buf) > 0) {
setenv("TZ", buf, 1); setenv("TZ", buf, 1);
}
} }
// get and set default timezone // get and set default timezone
tzset(); tzset();