提交 f2b4cca2 编写于 作者: C Cary Xu

fix: init buffer to avoid invalid write

上级 890075ef
...@@ -893,7 +893,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * ...@@ -893,7 +893,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo)); memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo));
} }
char tmp[32]; char tmp[32] = {0};
sprintf(tmp, ".%s", fraction); sprintf(tmp, ".%s", fraction);
memcpy(tzInfo, tmp, fracLen); memcpy(tzInfo, tmp, fracLen);
len += fracLen; len += fracLen;
......
...@@ -41,7 +41,7 @@ uint64_t schGenUUID(void) { ...@@ -41,7 +41,7 @@ uint64_t schGenUUID(void) {
static int32_t requestSerialId = 0; static int32_t requestSerialId = 0;
if (hashId == 0) { if (hashId == 0) {
char uid[64]; char uid[64] = {0};
int32_t code = taosGetSystemUUID(uid, tListLen(uid)); int32_t code = taosGetSystemUUID(uid, tListLen(uid));
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
qError("Failed to get the system uid, reason:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); qError("Failed to get the system uid, reason:%s", tstrerror(TAOS_SYSTEM_ERROR(errno)));
......
...@@ -67,7 +67,7 @@ static int32_t streamBuildExecMsg(SStreamTask* pTask, SArray* data, SRpcMsg* pMs ...@@ -67,7 +67,7 @@ static int32_t streamBuildExecMsg(SStreamTask* pTask, SArray* data, SRpcMsg* pMs
} else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { } else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) {
// TODO use general name rule of schemaless // TODO use general name rule of schemaless
char ctbName[TSDB_TABLE_FNAME_LEN + 22]; char ctbName[TSDB_TABLE_FNAME_LEN + 22] = {0};
// all groupId must be the same in an array // all groupId must be the same in an array
SSDataBlock* pBlock = taosArrayGet(data, 0); SSDataBlock* pBlock = taosArrayGet(data, 0);
sprintf(ctbName, "%s:%ld", pTask->shuffleDispatcher.stbFullName, pBlock->info.groupId); sprintf(ctbName, "%s:%ld", pTask->shuffleDispatcher.stbFullName, pBlock->info.groupId);
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
int32_t ret = 0; int32_t ret = 0;
char logBuf[128]; char logBuf[128] = {0};
snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesCb== term:%lu", ths->pRaftStore->currentTerm); snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesCb== term:%lu", ths->pRaftStore->currentTerm);
syncAppendEntriesLog2(logBuf, pMsg); syncAppendEntriesLog2(logBuf, pMsg);
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg) { int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg) {
int32_t ret = 0; int32_t ret = 0;
char logBuf[128]; char logBuf[128] = {0};
snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesReplyCb== term:%lu", ths->pRaftStore->currentTerm); snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesReplyCb== term:%lu", ths->pRaftStore->currentTerm);
syncAppendEntriesReplyLog2(logBuf, pMsg); syncAppendEntriesReplyLog2(logBuf, pMsg);
...@@ -57,7 +57,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p ...@@ -57,7 +57,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
// } // }
if (pMsg->term > ths->pRaftStore->currentTerm) { if (pMsg->term > ths->pRaftStore->currentTerm) {
char logBuf[128]; char logBuf[128] = {0};
snprintf(logBuf, sizeof(logBuf), "syncNodeOnAppendEntriesReplyCb error term, receive:%lu current:%lu", pMsg->term, snprintf(logBuf, sizeof(logBuf), "syncNodeOnAppendEntriesReplyCb error term, receive:%lu current:%lu", pMsg->term,
ths->pRaftStore->currentTerm); ths->pRaftStore->currentTerm);
syncNodeLog2(logBuf, ths); syncNodeLog2(logBuf, ths);
......
...@@ -74,7 +74,7 @@ int32_t syncIOSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) { ...@@ -74,7 +74,7 @@ int32_t syncIOSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
{ {
syncUtilMsgNtoH(pMsg->pCont); syncUtilMsgNtoH(pMsg->pCont);
char logBuf[256]; char logBuf[256] = {0};
snprintf(logBuf, sizeof(logBuf), "==syncIOSendMsg== %s:%d", pEpSet->eps[0].fqdn, pEpSet->eps[0].port); snprintf(logBuf, sizeof(logBuf), "==syncIOSendMsg== %s:%d", pEpSet->eps[0].fqdn, pEpSet->eps[0].port);
syncRpcMsgLog2(logBuf, pMsg); syncRpcMsgLog2(logBuf, pMsg);
...@@ -89,7 +89,7 @@ int32_t syncIOSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) { ...@@ -89,7 +89,7 @@ int32_t syncIOSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
int32_t syncIOEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) { int32_t syncIOEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
int32_t ret = 0; int32_t ret = 0;
char logBuf[128]; char logBuf[128] = {0};
syncRpcMsgLog2((char *)"==syncIOEqMsg==", pMsg); syncRpcMsgLog2((char *)"==syncIOEqMsg==", pMsg);
SRpcMsg *pTemp; SRpcMsg *pTemp;
......
...@@ -76,7 +76,7 @@ SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaf ...@@ -76,7 +76,7 @@ SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaf
} }
cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) {
char u64buf[128]; char u64buf[128] = {0};
cJSON *pRoot = cJSON_CreateObject(); cJSON *pRoot = cJSON_CreateObject();
if (pSyncIndexMgr != NULL) { if (pSyncIndexMgr != NULL) {
......
...@@ -1338,7 +1338,7 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) { ...@@ -1338,7 +1338,7 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
// on message ---- // on message ----
int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) { int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
// log state // log state
char logBuf[1024]; char logBuf[1024] = {0};
snprintf(logBuf, sizeof(logBuf), snprintf(logBuf, sizeof(logBuf),
"==syncNodeOnPingCb== vgId:%d, state: %d, %s, term:%lu electTimerLogicClock:%lu, " "==syncNodeOnPingCb== vgId:%d, state: %d, %s, term:%lu electTimerLogicClock:%lu, "
"electTimerLogicClockUser:%lu, electTimerMS:%d", "electTimerLogicClockUser:%lu, electTimerMS:%d",
......
...@@ -442,7 +442,7 @@ SyncPing* syncPingFromRpcMsg2(const SRpcMsg* pRpcMsg) { ...@@ -442,7 +442,7 @@ SyncPing* syncPingFromRpcMsg2(const SRpcMsg* pRpcMsg) {
} }
cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON* syncPing2Json(const SyncPing* pMsg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pMsg != NULL) { if (pMsg != NULL) {
...@@ -456,7 +456,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { ...@@ -456,7 +456,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) {
{ {
uint64_t u64 = pMsg->srcId.addr; uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId; cJSON* pTmp = pSrcId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -471,7 +471,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { ...@@ -471,7 +471,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) {
{ {
uint64_t u64 = pMsg->destId.addr; uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId; cJSON* pTmp = pDestId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -702,7 +702,7 @@ SyncPingReply* syncPingReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) { ...@@ -702,7 +702,7 @@ SyncPingReply* syncPingReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) {
} }
cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pMsg != NULL) { if (pMsg != NULL) {
...@@ -716,7 +716,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { ...@@ -716,7 +716,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
{ {
uint64_t u64 = pMsg->srcId.addr; uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId; cJSON* pTmp = pSrcId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -731,7 +731,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { ...@@ -731,7 +731,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
{ {
uint64_t u64 = pMsg->destId.addr; uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId; cJSON* pTmp = pDestId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -995,7 +995,7 @@ SyncRequestVote* syncRequestVoteFromRpcMsg2(const SRpcMsg* pRpcMsg) { ...@@ -995,7 +995,7 @@ SyncRequestVote* syncRequestVoteFromRpcMsg2(const SRpcMsg* pRpcMsg) {
} }
cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pMsg != NULL) { if (pMsg != NULL) {
...@@ -1009,7 +1009,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { ...@@ -1009,7 +1009,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
{ {
uint64_t u64 = pMsg->srcId.addr; uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId; cJSON* pTmp = pSrcId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1023,7 +1023,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { ...@@ -1023,7 +1023,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
{ {
uint64_t u64 = pMsg->destId.addr; uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId; cJSON* pTmp = pDestId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1144,7 +1144,7 @@ SyncRequestVoteReply* syncRequestVoteReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) { ...@@ -1144,7 +1144,7 @@ SyncRequestVoteReply* syncRequestVoteReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) {
} }
cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pMsg != NULL) { if (pMsg != NULL) {
...@@ -1158,7 +1158,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { ...@@ -1158,7 +1158,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) {
{ {
uint64_t u64 = pMsg->srcId.addr; uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId; cJSON* pTmp = pSrcId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1172,7 +1172,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { ...@@ -1172,7 +1172,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) {
{ {
uint64_t u64 = pMsg->destId.addr; uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId; cJSON* pTmp = pDestId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1292,7 +1292,7 @@ SyncAppendEntries* syncAppendEntriesFromRpcMsg2(const SRpcMsg* pRpcMsg) { ...@@ -1292,7 +1292,7 @@ SyncAppendEntries* syncAppendEntriesFromRpcMsg2(const SRpcMsg* pRpcMsg) {
} }
cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pMsg != NULL) { if (pMsg != NULL) {
...@@ -1306,7 +1306,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { ...@@ -1306,7 +1306,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
{ {
uint64_t u64 = pMsg->srcId.addr; uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId; cJSON* pTmp = pSrcId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1321,7 +1321,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { ...@@ -1321,7 +1321,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
{ {
uint64_t u64 = pMsg->destId.addr; uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId; cJSON* pTmp = pDestId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1456,7 +1456,7 @@ SyncAppendEntriesReply* syncAppendEntriesReplyFromRpcMsg2(const SRpcMsg* pRpcMsg ...@@ -1456,7 +1456,7 @@ SyncAppendEntriesReply* syncAppendEntriesReplyFromRpcMsg2(const SRpcMsg* pRpcMsg
} }
cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pMsg != NULL) { if (pMsg != NULL) {
...@@ -1470,7 +1470,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { ...@@ -1470,7 +1470,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
{ {
uint64_t u64 = pMsg->srcId.addr; uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId; cJSON* pTmp = pSrcId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1485,7 +1485,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { ...@@ -1485,7 +1485,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
{ {
uint64_t u64 = pMsg->destId.addr; uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId; cJSON* pTmp = pDestId;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddStringToObject(pTmp, "addr_host", host);
...@@ -1624,7 +1624,7 @@ void syncApplyMsg2OriginalRpcMsg(const SyncApplyMsg* pMsg, SRpcMsg* pOriginalRpc ...@@ -1624,7 +1624,7 @@ void syncApplyMsg2OriginalRpcMsg(const SyncApplyMsg* pMsg, SRpcMsg* pOriginalRpc
} }
cJSON* syncApplyMsg2Json(const SyncApplyMsg* pMsg) { cJSON* syncApplyMsg2Json(const SyncApplyMsg* pMsg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pMsg != NULL) { if (pMsg != NULL) {
......
...@@ -28,7 +28,7 @@ SRaftCfg *raftCfgOpen(const char *path) { ...@@ -28,7 +28,7 @@ SRaftCfg *raftCfgOpen(const char *path) {
taosLSeekFile(pCfg->pFile, 0, SEEK_SET); taosLSeekFile(pCfg->pFile, 0, SEEK_SET);
char buf[1024]; char buf[1024] = {0};
int len = taosReadFile(pCfg->pFile, buf, sizeof(buf)); int len = taosReadFile(pCfg->pFile, buf, sizeof(buf));
assert(len > 0); assert(len > 0);
...@@ -51,7 +51,7 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) { ...@@ -51,7 +51,7 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) {
char *s = raftCfg2Str(pRaftCfg); char *s = raftCfg2Str(pRaftCfg);
taosLSeekFile(pRaftCfg->pFile, 0, SEEK_SET); taosLSeekFile(pRaftCfg->pFile, 0, SEEK_SET);
char buf[CONFIG_FILE_LEN]; char buf[CONFIG_FILE_LEN] = {0};
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
ASSERT(strlen(s) + 1 <= CONFIG_FILE_LEN); ASSERT(strlen(s) + 1 <= CONFIG_FILE_LEN);
snprintf(buf, sizeof(buf), "%s", s); snprintf(buf, sizeof(buf), "%s", s);
...@@ -67,7 +67,7 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) { ...@@ -67,7 +67,7 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) {
} }
cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) { cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) {
char u64buf[128]; char u64buf[128] = {0};
cJSON *pRoot = cJSON_CreateObject(); cJSON *pRoot = cJSON_CreateObject();
if (pSyncCfg != NULL) { if (pSyncCfg != NULL) {
...@@ -172,7 +172,7 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, int8_t isStandBy, const char *path) { ...@@ -172,7 +172,7 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, int8_t isStandBy, const char *path) {
raftCfg.isStandBy = isStandBy; raftCfg.isStandBy = isStandBy;
char * s = raftCfg2Str(&raftCfg); char * s = raftCfg2Str(&raftCfg);
char buf[CONFIG_FILE_LEN]; char buf[CONFIG_FILE_LEN] = {0};
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
ASSERT(strlen(s) + 1 <= CONFIG_FILE_LEN); ASSERT(strlen(s) + 1 <= CONFIG_FILE_LEN);
snprintf(buf, sizeof(buf), "%s", s); snprintf(buf, sizeof(buf), "%s", s);
......
...@@ -107,7 +107,7 @@ SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len) { ...@@ -107,7 +107,7 @@ SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len) {
} }
cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) { cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
if (pEntry != NULL) { if (pEntry != NULL) {
......
...@@ -190,7 +190,7 @@ SSyncRaftEntry* logStoreGetLastEntry(SSyncLogStore* pLogStore) { ...@@ -190,7 +190,7 @@ SSyncRaftEntry* logStoreGetLastEntry(SSyncLogStore* pLogStore) {
} }
cJSON* logStore2Json(SSyncLogStore* pLogStore) { cJSON* logStore2Json(SSyncLogStore* pLogStore) {
char u64buf[128]; char u64buf[128] = {0};
SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data; SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data;
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
...@@ -227,7 +227,7 @@ char* logStore2Str(SSyncLogStore* pLogStore) { ...@@ -227,7 +227,7 @@ char* logStore2Str(SSyncLogStore* pLogStore) {
} }
cJSON* logStoreSimple2Json(SSyncLogStore* pLogStore) { cJSON* logStoreSimple2Json(SSyncLogStore* pLogStore) {
char u64buf[128]; char u64buf[128] = {0};
SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data; SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data;
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
......
...@@ -34,7 +34,7 @@ SRaftStore *raftStoreOpen(const char *path) { ...@@ -34,7 +34,7 @@ SRaftStore *raftStoreOpen(const char *path) {
memset(pRaftStore, 0, sizeof(*pRaftStore)); memset(pRaftStore, 0, sizeof(*pRaftStore));
snprintf(pRaftStore->path, sizeof(pRaftStore->path), "%s", path); snprintf(pRaftStore->path, sizeof(pRaftStore->path), "%s", path);
char storeBuf[RAFT_STORE_BLOCK_SIZE]; char storeBuf[RAFT_STORE_BLOCK_SIZE] = {0};
memset(storeBuf, 0, sizeof(storeBuf)); memset(storeBuf, 0, sizeof(storeBuf));
if (!raftStoreFileExist(pRaftStore->path)) { if (!raftStoreFileExist(pRaftStore->path)) {
...@@ -84,7 +84,7 @@ int32_t raftStorePersist(SRaftStore *pRaftStore) { ...@@ -84,7 +84,7 @@ int32_t raftStorePersist(SRaftStore *pRaftStore) {
assert(pRaftStore != NULL); assert(pRaftStore != NULL);
int32_t ret; int32_t ret;
char storeBuf[RAFT_STORE_BLOCK_SIZE]; char storeBuf[RAFT_STORE_BLOCK_SIZE] = {0};
ret = raftStoreSerialize(pRaftStore, storeBuf, sizeof(storeBuf)); ret = raftStoreSerialize(pRaftStore, storeBuf, sizeof(storeBuf));
assert(ret == 0); assert(ret == 0);
...@@ -107,7 +107,7 @@ int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) { ...@@ -107,7 +107,7 @@ int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) {
cJSON *pRoot = cJSON_CreateObject(); cJSON *pRoot = cJSON_CreateObject();
char u64Buf[128]; char u64Buf[128] = {0};
snprintf(u64Buf, sizeof(u64Buf), "%lu", pRaftStore->currentTerm); snprintf(u64Buf, sizeof(u64Buf), "%lu", pRaftStore->currentTerm);
cJSON_AddStringToObject(pRoot, "current_term", u64Buf); cJSON_AddStringToObject(pRoot, "current_term", u64Buf);
...@@ -117,7 +117,7 @@ int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) { ...@@ -117,7 +117,7 @@ int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) {
cJSON_AddNumberToObject(pRoot, "vote_for_vgid", pRaftStore->voteFor.vgId); cJSON_AddNumberToObject(pRoot, "vote_for_vgid", pRaftStore->voteFor.vgId);
uint64_t u64 = pRaftStore->voteFor.addr; uint64_t u64 = pRaftStore->voteFor.addr;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pRoot, "addr_host", host); cJSON_AddStringToObject(pRoot, "addr_host", host);
...@@ -184,7 +184,7 @@ void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term) { ...@@ -184,7 +184,7 @@ void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term) {
int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson) { return 0; } int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson) { return 0; }
cJSON *raftStore2Json(SRaftStore *pRaftStore) { cJSON *raftStore2Json(SRaftStore *pRaftStore) {
char u64buf[128]; char u64buf[128] = {0};
cJSON *pRoot = cJSON_CreateObject(); cJSON *pRoot = cJSON_CreateObject();
if (pRaftStore != NULL) { if (pRaftStore != NULL) {
...@@ -196,7 +196,7 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { ...@@ -196,7 +196,7 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) {
cJSON_AddStringToObject(pVoteFor, "addr", u64buf); cJSON_AddStringToObject(pVoteFor, "addr", u64buf);
{ {
uint64_t u64 = pRaftStore->voteFor.addr; uint64_t u64 = pRaftStore->voteFor.addr;
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(u64, host, sizeof(host), &port); syncUtilU642Addr(u64, host, sizeof(host), &port);
cJSON_AddStringToObject(pVoteFor, "addr_host", host); cJSON_AddStringToObject(pVoteFor, "addr_host", host);
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
int32_t ret = 0; int32_t ret = 0;
char logBuf[128]; char logBuf[128] = {0};
snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteCb== term:%lu", ths->pRaftStore->currentTerm); snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteCb== term:%lu", ths->pRaftStore->currentTerm);
syncRequestVoteLog2(logBuf, pMsg); syncRequestVoteLog2(logBuf, pMsg);
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) { int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) {
int32_t ret = 0; int32_t ret = 0;
char logBuf[128]; char logBuf[128] = {0};
snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteReplyCb== term:%lu", ths->pRaftStore->currentTerm); snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteReplyCb== term:%lu", ths->pRaftStore->currentTerm);
syncRequestVoteReplyLog2(logBuf, pMsg); syncRequestVoteReplyLog2(logBuf, pMsg);
...@@ -56,7 +56,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) ...@@ -56,7 +56,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg)
// } // }
if (pMsg->term > ths->pRaftStore->currentTerm) { if (pMsg->term > ths->pRaftStore->currentTerm) {
char logBuf[128]; char logBuf[128] = {0};
snprintf(logBuf, sizeof(logBuf), "syncNodeOnRequestVoteReplyCb error term, receive:%lu current:%lu", pMsg->term, snprintf(logBuf, sizeof(logBuf), "syncNodeOnRequestVoteReplyCb error term, receive:%lu current:%lu", pMsg->term,
ths->pRaftStore->currentTerm); ths->pRaftStore->currentTerm);
syncNodePrint2(logBuf, ths); syncNodePrint2(logBuf, ths);
......
...@@ -43,7 +43,7 @@ void syncUtilnodeInfo2EpSet(const SNodeInfo* pNodeInfo, SEpSet* pEpSet) { ...@@ -43,7 +43,7 @@ void syncUtilnodeInfo2EpSet(const SNodeInfo* pNodeInfo, SEpSet* pEpSet) {
} }
void syncUtilraftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet) { void syncUtilraftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet) {
char host[TSDB_FQDN_LEN]; char host[TSDB_FQDN_LEN] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(raftId->addr, host, sizeof(host), &port); syncUtilU642Addr(raftId->addr, host, sizeof(host), &port);
...@@ -62,7 +62,7 @@ void syncUtilraftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet) { ...@@ -62,7 +62,7 @@ void syncUtilraftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet) {
void syncUtilnodeInfo2raftId(const SNodeInfo* pNodeInfo, SyncGroupId vgId, SRaftId* raftId) { void syncUtilnodeInfo2raftId(const SNodeInfo* pNodeInfo, SyncGroupId vgId, SRaftId* raftId) {
uint32_t ipv4 = taosGetIpv4FromFqdn(pNodeInfo->nodeFqdn); uint32_t ipv4 = taosGetIpv4FromFqdn(pNodeInfo->nodeFqdn);
assert(ipv4 != 0xFFFFFFFF); assert(ipv4 != 0xFFFFFFFF);
char ipbuf[128]; char ipbuf[128] = {0};
tinet_ntoa(ipbuf, ipv4); tinet_ntoa(ipbuf, ipv4);
raftId->addr = syncUtilAddr2U64(ipbuf, pNodeInfo->nodePort); raftId->addr = syncUtilAddr2U64(ipbuf, pNodeInfo->nodePort);
raftId->vgId = vgId; raftId->vgId = vgId;
...@@ -106,7 +106,7 @@ int32_t syncUtilElectRandomMS(int32_t min, int32_t max) { ...@@ -106,7 +106,7 @@ int32_t syncUtilElectRandomMS(int32_t min, int32_t max) {
int32_t syncUtilQuorum(int32_t replicaNum) { return replicaNum / 2 + 1; } int32_t syncUtilQuorum(int32_t replicaNum) { return replicaNum / 2 + 1; }
cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p) { cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
cJSON_AddStringToObject(pRoot, "nodeFqdn", p->nodeFqdn); cJSON_AddStringToObject(pRoot, "nodeFqdn", p->nodeFqdn);
...@@ -118,12 +118,12 @@ cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p) { ...@@ -118,12 +118,12 @@ cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p) {
} }
cJSON* syncUtilRaftId2Json(const SRaftId* p) { cJSON* syncUtilRaftId2Json(const SRaftId* p) {
char u64buf[128]; char u64buf[128] = {0};
cJSON* pRoot = cJSON_CreateObject(); cJSON* pRoot = cJSON_CreateObject();
snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", p->addr); snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", p->addr);
cJSON_AddStringToObject(pRoot, "addr", u64buf); cJSON_AddStringToObject(pRoot, "addr", u64buf);
char host[128]; char host[128] = {0};
uint16_t port; uint16_t port;
syncUtilU642Addr(p->addr, host, sizeof(host), &port); syncUtilU642Addr(p->addr, host, sizeof(host), &port);
cJSON_AddStringToObject(pRoot, "host", host); cJSON_AddStringToObject(pRoot, "host", host);
......
...@@ -90,7 +90,7 @@ void voteGrantedReset(SVotesGranted *pVotesGranted, SyncTerm term) { ...@@ -90,7 +90,7 @@ void voteGrantedReset(SVotesGranted *pVotesGranted, SyncTerm term) {
} }
cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) {
char u64buf[128]; char u64buf[128] = {0};
cJSON *pRoot = cJSON_CreateObject(); cJSON *pRoot = cJSON_CreateObject();
if (pVotesGranted != NULL) { if (pVotesGranted != NULL) {
...@@ -220,7 +220,7 @@ void votesRespondReset(SVotesRespond *pVotesRespond, SyncTerm term) { ...@@ -220,7 +220,7 @@ void votesRespondReset(SVotesRespond *pVotesRespond, SyncTerm term) {
} }
cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) {
char u64buf[128]; char u64buf[128] = {0};
cJSON *pRoot = cJSON_CreateObject(); cJSON *pRoot = cJSON_CreateObject();
if (pVotesRespond != NULL) { if (pVotesRespond != NULL) {
......
...@@ -42,7 +42,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { ...@@ -42,7 +42,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
} }
if (cbMeta.index > beginIndex) { if (cbMeta.index > beginIndex) {
char logBuf[256]; char logBuf[256] = {0};
snprintf(logBuf, sizeof(logBuf), snprintf(logBuf, sizeof(logBuf),
"==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm, "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm,
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag); cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag);
...@@ -53,7 +53,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { ...@@ -53,7 +53,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
} }
void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
char logBuf[256]; char logBuf[256] = {0};
snprintf(logBuf, sizeof(logBuf), snprintf(logBuf, sizeof(logBuf),
"==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm, "==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm,
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag); cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册