diff --git a/include/os/osLocale.h b/include/os/osLocale.h index d7a3540887..78d5f948b0 100644 --- a/include/os/osLocale.h +++ b/include/os/osLocale.h @@ -28,9 +28,9 @@ extern "C" { #define setlocale SETLOCALE_FUNC_TAOS_FORBID #endif -char *taosCharsetReplace(char *charsetstr); -void taosGetSystemLocale(char *outLocale, char *outCharset); -int32_t taosSetSystemLocale(const char *inLocale); +char *taosCharsetReplace(char *charsetstr); +void taosGetSystemLocale(char *outLocale, char *outCharset); +int32_t taosSetSystemLocale(const char *inLocale); #ifdef __cplusplus } diff --git a/source/os/src/osLocale.c b/source/os/src/osLocale.c index cb0a2646fd..484436fafe 100644 --- a/source/os/src/osLocale.c +++ b/source/os/src/osLocale.c @@ -87,8 +87,7 @@ int32_t taosSetSystemLocale(const char *inLocale) { return terrno; } - (void)memcpy(tsLocale, inLocale, strlen(inLocale) + 1); - + tstrncpy(tsLocale, locale, TD_LOCALE_LEN); return 0; } diff --git a/source/os/test/osEnvTests.cpp b/source/os/test/osEnvTests.cpp index d5b3cac8a6..6af6f84b68 100644 --- a/source/os/test/osEnvTests.cpp +++ b/source/os/test/osEnvTests.cpp @@ -84,9 +84,8 @@ TEST(osEnvTests, osSufficient) { ret = osTempSpaceSufficient(); EXPECT_EQ(ret, true); - osSetSystemLocale(NULL, NULL); - osSetSystemLocale(NULL, NULL); - osSetSystemLocale("1", "2"); + taosSetSystemLocale(NULL); + taosSetSystemLocale("1"); osSetProcPath(1, NULL); osSetProcPath(0, (char **)&ret);