From edfeb463fba2e73e63d3f0ed211c6cada060d5d2 Mon Sep 17 00:00:00 2001 From: gitwuxd Date: Wed, 25 May 2022 20:49:49 +0800 Subject: [PATCH] modify the code xts_dcts.sever Signed-off-by: gitwuxd --- common/shm_utils.cpp | 11 ++++++++--- .../disdata_func_test.cpp | 19 +++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/common/shm_utils.cpp b/common/shm_utils.cpp index 232511e..b5dc754 100644 --- a/common/shm_utils.cpp +++ b/common/shm_utils.cpp @@ -119,7 +119,7 @@ int waitDataWithCode(char* code, char* data) int writeCodeDataToShm(int code, char* buf) { - char str[1024] = { 0 }; + char str[MAX_DATA_LENGTH] = { 0 }; char codeStr[5] = { 0 }; char* str2 = Int2String(code, codeStr); if (str2 == nullptr) { @@ -128,11 +128,16 @@ int writeCodeDataToShm(int code, char* buf) if (strcpy_s(str, strlen(codeStr) + 1, codeStr) != EOK) { return -1; } - strcat(str, ":"); + if (strcat_s(str, strlen(":") + 1, ":") != EOK) { + return -1; + } + if (buf == nullptr) { return -1; } - strcat(str, buf); + if (strcat_s(str, strlen(buf) + 1, buf) != EOK) { + return -1; + } int nres = writeDataToShm(str); if (nres == -1) { return -1; diff --git a/distributeddatamgr/cpptest/distributed_kv_store/disdata_func_test.cpp b/distributeddatamgr/cpptest/distributed_kv_store/disdata_func_test.cpp index f41c1a1..9104948 100755 --- a/distributeddatamgr/cpptest/distributed_kv_store/disdata_func_test.cpp +++ b/distributeddatamgr/cpptest/distributed_kv_store/disdata_func_test.cpp @@ -98,8 +98,7 @@ void KvStoreSyncCallbackTestImpl::SyncCompleted(const std::map