From 97850ae8ffc0155cd6dfec64c18d53fe981b438c Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Fri, 3 Jul 2020 18:47:12 +0800 Subject: [PATCH] fix two bugs 1. crash when retrieve data 2. invalid read when query a super table which has no sub tables --- src/client/src/tscAsync.c | 2 +- src/client/src/tscServer.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 100c9029a7..3fed3e4d67 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -235,7 +235,7 @@ void taos_fetch_rows_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, int), voi (*pSql->fetchFp)(param, pSql, 0); } return; - } else if (pCmd->command == TSDB_SQL_RETRIEVE) { + } else if (pCmd->command == TSDB_SQL_RETRIEVE || pCmd->command == TSDB_SQL_RETRIEVE_LOCALMERGE) { // in case of show command, return no data (*pSql->fetchFp)(param, pSql, 0); } else { diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 1b2334b998..b7c0d43ef0 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -46,10 +46,13 @@ static int32_t minMsgSize() { return tsRpcHeadSize + 100; } static void tscSetDnodeIpList(SSqlObj* pSql, SCMVgroupInfo* pVgroupInfo) { SRpcIpSet* pIpList = &pSql->ipList; - - pIpList->numOfIps = pVgroupInfo->numOfIps; pIpList->inUse = 0; + if (pVgroupInfo == NULL) { + pIpList->numOfIps = 0; + return; + } + pIpList->numOfIps = pVgroupInfo->numOfIps; for(int32_t i = 0; i < pVgroupInfo->numOfIps; ++i) { strcpy(pIpList->fqdn[i], pVgroupInfo->ipAddr[i].fqdn); pIpList->port[i] = pVgroupInfo->ipAddr[i].port; @@ -539,14 +542,18 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char int32_t index = pTableMetaInfo->vgroupIndex; assert(index >= 0); - pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index]; + if (pTableMetaInfo->vgroupList->numOfVgroups > 0) { + pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index]; + } tscDebug("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, pTableMetaInfo->vgroupList->numOfVgroups); } else { pVgroupInfo = &pTableMeta->vgroupInfo; } tscSetDnodeIpList(pSql, pVgroupInfo); - pQueryMsg->head.vgId = htonl(pVgroupInfo->vgId); + if (pVgroupInfo != NULL) { + pQueryMsg->head.vgId = htonl(pVgroupInfo->vgId); + } STableIdInfo *pTableIdInfo = (STableIdInfo *)pMsg; pTableIdInfo->tid = htonl(pTableMeta->sid); -- GitLab