fix invalid read

This commit is contained in:
yihaoDeng 2024-09-20 17:45:27 +08:00
parent 0fa0d64bb5
commit 6ba0c720da
5 changed files with 23 additions and 14 deletions

View File

@ -37,7 +37,6 @@ void setQueryRequest(int64_t rId) {
pReq->isQuery = true; pReq->isQuery = true;
(void)releaseRequest(rId); (void)releaseRequest(rId);
} }
} }
static bool stringLengthCheck(const char* str, size_t maxsize) { static bool stringLengthCheck(const char* str, size_t maxsize) {
@ -2245,7 +2244,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
} else if (tTagIsJson(data)) { } else if (tTagIsJson(data)) {
char* jsonString = NULL; char* jsonString = NULL;
parseTagDatatoJson(data, &jsonString); parseTagDatatoJson(data, &jsonString);
if(jsonString == NULL) { if (jsonString == NULL) {
tscError("doConvertJson error: parseTagDatatoJson failed"); tscError("doConvertJson error: parseTagDatatoJson failed");
return terrno; return terrno;
} }
@ -2517,10 +2516,10 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
void* clientRpc = NULL; void* clientRpc = NULL;
SServerStatusRsp statusRsp = {0}; SServerStatusRsp statusRsp = {0};
SEpSet epSet = {.inUse = 0, .numOfEps = 1}; SEpSet epSet = {.inUse = 0, .numOfEps = 1};
SRpcMsg rpcMsg = {.info.ahandle = (void*)0x9526, .msgType = TDMT_DND_SERVER_STATUS}; SRpcMsg rpcMsg = {.info.ahandle = (void*)0x9527, .info.notFreeAhandle = 1, .msgType = TDMT_DND_SERVER_STATUS};
SRpcMsg rpcRsp = {0}; SRpcMsg rpcRsp = {0};
SRpcInit rpcInit = {0}; SRpcInit rpcInit = {0};
char pass[TSDB_PASSWORD_LEN + 1] = {0}; char pass[TSDB_PASSWORD_LEN + 1] = {0};
rpcInit.label = "CHK"; rpcInit.label = "CHK";
rpcInit.numOfThreads = 1; rpcInit.numOfThreads = 1;
@ -3032,7 +3031,8 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param
void doRequestCallback(SRequestObj* pRequest, int32_t code) { void doRequestCallback(SRequestObj* pRequest, int32_t code) {
pRequest->inCallback = true; pRequest->inCallback = true;
int64_t this = pRequest->self; int64_t this = pRequest->self;
if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && pRequest->isQuery && (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && pRequest->isQuery &&
(code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) {
code = TSDB_CODE_SUCCESS; code = TSDB_CODE_SUCCESS;
pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
} }

View File

@ -69,6 +69,7 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
.contLen = contLen, .contLen = contLen,
.msgType = TDMT_MND_RETRIEVE_IP_WHITE, .msgType = TDMT_MND_RETRIEVE_IP_WHITE,
.info.ahandle = (void *)0x9527, .info.ahandle = (void *)0x9527,
.info.notFreeAhandle = 1,
.info.refId = 0, .info.refId = 0,
.info.noResp = 0, .info.noResp = 0,
.info.handle = 0}; .info.handle = 0};
@ -185,6 +186,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
.contLen = contLen, .contLen = contLen,
.msgType = TDMT_MND_STATUS, .msgType = TDMT_MND_STATUS,
.info.ahandle = (void *)0x9527, .info.ahandle = (void *)0x9527,
.info.notFreeAhandle = 1,
.info.refId = 0, .info.refId = 0,
.info.noResp = 0, .info.noResp = 0,
.info.handle = 0}; .info.handle = 0};
@ -234,6 +236,7 @@ void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) {
.contLen = contLen, .contLen = contLen,
.msgType = TDMT_MND_NOTIFY, .msgType = TDMT_MND_NOTIFY,
.info.ahandle = (void *)0x9527, .info.ahandle = (void *)0x9527,
.info.notFreeAhandle = 1,
.info.refId = 0, .info.refId = 0,
.info.noResp = 1, .info.noResp = 1,
.info.handle = 0}; .info.handle = 0};
@ -483,7 +486,7 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
} }
int32_t len = blockEncode(pBlock, pStart, numOfCols); int32_t len = blockEncode(pBlock, pStart, numOfCols);
if(len < 0) { if (len < 0) {
dError("failed to retrieve data since %s", tstrerror(code)); dError("failed to retrieve data since %s", tstrerror(code));
blockDataDestroy(pBlock); blockDataDestroy(pBlock);
rpcFreeCont(pRsp); rpcFreeCont(pRsp);

View File

@ -210,8 +210,11 @@ static void mndPullupGrant(SMnode *pMnode) {
int32_t contLen = 0; int32_t contLen = 0;
void *pReq = mndBuildTimerMsg(&contLen); void *pReq = mndBuildTimerMsg(&contLen);
if (pReq != NULL) { if (pReq != NULL) {
SRpcMsg rpcMsg = { SRpcMsg rpcMsg = {.msgType = TDMT_MND_GRANT_HB_TIMER,
.msgType = TDMT_MND_GRANT_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9527}; .pCont = pReq,
.contLen = contLen,
.info.notFreeAhandle = 1,
.info.ahandle = (void *)0x9527};
// TODO check return value // TODO check return value
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
} }
@ -222,8 +225,11 @@ static void mndIncreaseUpTime(SMnode *pMnode) {
int32_t contLen = 0; int32_t contLen = 0;
void *pReq = mndBuildTimerMsg(&contLen); void *pReq = mndBuildTimerMsg(&contLen);
if (pReq != NULL) { if (pReq != NULL) {
SRpcMsg rpcMsg = { SRpcMsg rpcMsg = {.msgType = TDMT_MND_UPTIME_TIMER,
.msgType = TDMT_MND_UPTIME_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9528}; .pCont = pReq,
.contLen = contLen,
.info.notFreeAhandle = 1,
.info.ahandle = (void *)0x9527};
// TODO check return value // TODO check return value
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
} }

View File

@ -403,7 +403,7 @@ int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) {
TAOS_RETURN(code); TAOS_RETURN(code);
} }
SRpcMsg rpcMsg = {0}; SRpcMsg rpcMsg = {0, .info.notFreeAhandle = 1};
int32_t ret = syncRespMgrGetAndDel(pNode->pSyncRespMgr, seq, &rpcMsg.info); int32_t ret = syncRespMgrGetAndDel(pNode->pSyncRespMgr, seq, &rpcMsg.info);
rpcMsg.code = TSDB_CODE_SYN_TIMEOUT; rpcMsg.code = TSDB_CODE_SYN_TIMEOUT;

View File

@ -61,7 +61,7 @@ static void shellWorkAsClient() {
uint64_t startTime = taosGetTimestampUs(); uint64_t startTime = taosGetTimestampUs();
for (int32_t i = 0; i < pArgs->pktNum; ++i) { for (int32_t i = 0; i < pArgs->pktNum; ++i) {
SRpcMsg rpcMsg = {.info.ahandle = (void *)0x9525, .msgType = TDMT_DND_NET_TEST}; SRpcMsg rpcMsg = {.info.ahandle = (void *)0x9525, .info.notFreeAhandle = 1, .msgType = TDMT_DND_NET_TEST};
rpcMsg.pCont = rpcMallocCont(pArgs->pktLen); rpcMsg.pCont = rpcMallocCont(pArgs->pktLen);
rpcMsg.contLen = pArgs->pktLen; rpcMsg.contLen = pArgs->pktLen;