From a4bd57e2f15a9b9366642a8883afc54b0fda5ea5 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 28 Aug 2024 21:26:06 +0800 Subject: [PATCH 1/4] fix: fix connect rsp msg except memory leak --- source/common/src/tmsg.c | 37 ++++++++++++++++++---------------- tests/parallel_test/cases.task | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 58a7f8f448..3c19528ceb 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5258,44 +5258,47 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); + int32_t ret = -1; - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->acctId) < 0) return -1; - if (tDecodeI64(&decoder, &pRsp->clusterId) < 0) return -1; - if (tDecodeU32(&decoder, &pRsp->connId) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->dnodeNum) < 0) return -1; - if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1; - if (tDecodeI8(&decoder, &pRsp->sysInfo) < 0) return -1; - if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1; - if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->svrTimestamp) < 0) return -1; - if (tDecodeCStrTo(&decoder, pRsp->sVer) < 0) return -1; - if (tDecodeCStrTo(&decoder, pRsp->sDetailVer) < 0) return -1; + if (tStartDecode(&decoder) < 0) goto _END; + if (tDecodeI32(&decoder, &pRsp->acctId) < 0) goto _END; + if (tDecodeI64(&decoder, &pRsp->clusterId) < 0) goto _END; + if (tDecodeU32(&decoder, &pRsp->connId) < 0) goto _END; + if (tDecodeI32(&decoder, &pRsp->dnodeNum) < 0) goto _END; + if (tDecodeI8(&decoder, &pRsp->superUser) < 0) goto _END; + if (tDecodeI8(&decoder, &pRsp->sysInfo) < 0) goto _END; + if (tDecodeI8(&decoder, &pRsp->connType) < 0) goto _END; + if (tDecodeSEpSet(&decoder,&pRsp->epSet) < 0) goto _END; + if (tDecodeI32(&decoder, &pRsp->svrTimestamp) < 0) goto _END; + if (tDecodeCStrTo(&decoder, pRsp->sVer) < 0) goto _END; + if (tDecodeCStrTo(&decoder, pRsp->sDetailVer) < 0) goto _END; if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI32(&decoder, &pRsp->passVer) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->passVer) < 0) goto _END; } else { pRsp->passVer = 0; } // since 3.0.7.0 if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI32(&decoder, &pRsp->authVer) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->authVer) < 0) goto _END; } else { pRsp->authVer = 0; } if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI64(&decoder, &pRsp->whiteListVer) < 0) return -1; + if (tDecodeI64(&decoder, &pRsp->whiteListVer) < 0) goto _END; } else { pRsp->whiteListVer = 0; } if (!tDecodeIsEnd(&decoder)) { - if (tDeserializeSMonitorParas(&decoder, &pRsp->monitorParas) < 0) return -1; + if (tDeserializeSMonitorParas(&decoder, &pRsp->monitorParas) < 0) goto _END; } tEndDecode(&decoder); + ret = 0; +_END: tDecoderClear(&decoder); - return 0; + return ret; } int32_t tSerializeSMTimerMsg(void *buf, int32_t bufLen, SMTimerReq *pReq) { diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 7a20898911..c729c74330 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -313,7 +313,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6 ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShell.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellError.py -,,n,system-test,python3 ./test.py -f 0-others/taosShellNetChk.py +,,y,system-test,python3 ./test.py -f 0-others/taosShellNetChk.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/telemetry.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/backquote_check.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosdMonitor.py From af5cd7a66e74d340682f65a3b834e58a154487cc Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 29 Aug 2024 09:26:45 +0800 Subject: [PATCH 2/4] fix: cases.tasks config sanitizer error --- tests/parallel_test/cases.task | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index c729c74330..119b16b26c 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -313,7 +313,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6 ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShell.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellError.py -,,y,system-test,python3 ./test.py -f 0-others/taosShellNetChk.py +,,y,system-test,./pytest.sh python3 python3 ./test.py -f 0-others/taosShellNetChk.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/telemetry.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/backquote_check.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosdMonitor.py From dbcd10df3c133f3005d49578006f073d47a3e784 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 29 Aug 2024 09:28:46 +0800 Subject: [PATCH 3/4] fix: cases.tasks config sanitizer error1 --- tests/parallel_test/cases.task | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 119b16b26c..8dfb6f6a00 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -313,7 +313,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6 ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShell.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellError.py -,,y,system-test,./pytest.sh python3 python3 ./test.py -f 0-others/taosShellNetChk.py +,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellNetChk.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/telemetry.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/backquote_check.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosdMonitor.py From ebbf7ee2866c426fd951b020a8251719b04fd238 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 29 Aug 2024 11:43:15 +0800 Subject: [PATCH 4/4] fix: add tDeserializeSClientHbBatchRsp leak memory --- source/common/src/tmsg.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 3c19528ceb..7973aa1b46 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -566,30 +566,34 @@ int32_t tSerializeSClientHbBatchRsp(void *buf, int32_t bufLen, const SClientHbBa int32_t tDeserializeSClientHbBatchRsp(void *buf, int32_t bufLen, SClientHbBatchRsp *pBatchRsp) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); + int32_t ret = -1; - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeI64(&decoder, &pBatchRsp->reqId) < 0) return -1; - if (tDecodeI64(&decoder, &pBatchRsp->rspId) < 0) return -1; - if (tDecodeI32(&decoder, &pBatchRsp->svrTimestamp) < 0) return -1; + if (tStartDecode(&decoder) < 0) goto _END; + if (tDecodeI64(&decoder, &pBatchRsp->reqId) < 0) goto _END; + if (tDecodeI64(&decoder, &pBatchRsp->rspId) < 0) goto _END; + if (tDecodeI32(&decoder, &pBatchRsp->svrTimestamp) < 0) goto _END; int32_t rspNum = 0; - if (tDecodeI32(&decoder, &rspNum) < 0) return -1; + if (tDecodeI32(&decoder, &rspNum) < 0) goto _END; if (pBatchRsp->rsps == NULL) { - if ((pBatchRsp->rsps = taosArrayInit(rspNum, sizeof(SClientHbRsp))) == NULL) return -1; + if ((pBatchRsp->rsps = taosArrayInit(rspNum, sizeof(SClientHbRsp))) == NULL) goto _END; } for (int32_t i = 0; i < rspNum; i++) { SClientHbRsp rsp = {0}; - if (tDeserializeSClientHbRsp(&decoder, &rsp) < 0) return -1; - if (taosArrayPush(pBatchRsp->rsps, &rsp) == NULL) return -1; + if (tDeserializeSClientHbRsp(&decoder, &rsp) < 0) goto _END; + if (taosArrayPush(pBatchRsp->rsps, &rsp) == NULL) goto _END; } if (!tDecodeIsEnd(&decoder)) { - if (tDeserializeSMonitorParas(&decoder, &pBatchRsp->monitorParas) < 0) return -1; + if (tDeserializeSMonitorParas(&decoder, &pBatchRsp->monitorParas) < 0) goto _END; } tEndDecode(&decoder); + ret = 0; + +_END: tDecoderClear(&decoder); - return 0; + return ret; } int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq) {