diff --git a/include/util/tdef.h b/include/util/tdef.h index 0a0fe22449..a2b014cc7e 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -184,6 +184,7 @@ typedef enum ELogicConditionType { #define TSDB_UNI_LEN 24 #define TSDB_USER_LEN TSDB_UNI_LEN +#define TSDB_POINTER_PRINT_BYTES 18 // 0x1122334455667788 // ACCOUNT is a 32 bit positive integer // this is the length of its string representation, including the terminator zero #define TSDB_ACCT_ID_LEN 11 diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index e75189e54a..5caeb2b43c 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -391,7 +391,7 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod nodesDestroyList(pParameterList); return TSDB_CODE_OUT_OF_MEMORY; } - char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + sizeof(pSrcFunc) + 1] = {0}; + char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0}; int32_t len = snprintf(name, sizeof(name) - 1, "%s.%p", (*pPartialFunc)->functionName, pSrcFunc); taosCreateMD5Hash(name, len); strncpy((*pPartialFunc)->node.aliasName, name, TSDB_COL_NAME_LEN - 1); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 010bbe6477..32d883d4ea 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1615,7 +1615,7 @@ static void partTagsSetAlias(char* pAlias, const char* pTableAlias, const char* int32_t len = snprintf(name, TSDB_COL_FNAME_LEN, "%s.%s", pTableAlias, pColName); taosCreateMD5Hash(name, len); - strcpy(pAlias, name); + strncpy(pAlias, name, TSDB_COL_NAME_LEN - 1); } static SNode* partTagsCreateWrapperFunc(const char* pFuncName, SNode* pNode) { @@ -2136,7 +2136,7 @@ static SNode* rewriteUniqueOptCreateFirstFunc(SFunctionNode* pSelectValue, SNode strcpy(pFunc->node.aliasName, pSelectValue->node.aliasName); } else { int64_t pointer = (int64_t)pFunc; - char name[TSDB_FUNC_NAME_LEN + sizeof(pointer) + TSDB_NAME_DELIMITER_LEN + 1] = {0}; + char name[TSDB_FUNC_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0}; int32_t len = snprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pFunc->functionName, pointer); taosCreateMD5Hash(name, len); strncpy(pFunc->node.aliasName, name, TSDB_COL_NAME_LEN - 1); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 674ec7ca70..7f27a0539d 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -388,7 +388,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) { } strcpy(pWStart->functionName, "_wstart"); int64_t pointer = (int64_t)pWStart; - char name[TSDB_COL_NAME_LEN + sizeof(pointer) + TSDB_NAME_DELIMITER_LEN + 1] = {0}; + char name[TSDB_COL_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0}; int32_t len = snprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pWStart->functionName, pointer); taosCreateMD5Hash(name, len); strncpy(pWStart->node.aliasName, name, TSDB_COL_NAME_LEN - 1); @@ -418,7 +418,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) { } strcpy(pWEnd->functionName, "_wend"); int64_t pointer = (int64_t)pWEnd; - char name[TSDB_COL_NAME_LEN + sizeof(pointer) + TSDB_NAME_DELIMITER_LEN + 1] = {0}; + char name[TSDB_COL_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0}; int32_t len = snprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pWEnd->functionName, pointer); taosCreateMD5Hash(name, len); strncpy(pWEnd->node.aliasName, name, TSDB_COL_NAME_LEN - 1);