fix: buffer overflow
This commit is contained in:
parent
11c0427b22
commit
bc44659826
|
@ -54,28 +54,27 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
||||||
|
|
||||||
tqDebug("s-task:%s build %d rows delete msg for table:%s", pIdStr, totalRows, stbFullName);
|
tqDebug("s-task:%s build %d rows delete msg for table:%s", pIdStr, totalRows, stbFullName);
|
||||||
|
|
||||||
char tbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE];
|
|
||||||
for (int32_t row = 0; row < totalRows; row++) {
|
for (int32_t row = 0; row < totalRows; row++) {
|
||||||
int64_t skey = *(int64_t*)colDataGetData(pStartTsCol, row);
|
int64_t skey = *(int64_t*)colDataGetData(pStartTsCol, row);
|
||||||
int64_t ekey = *(int64_t*)colDataGetData(pEndTsCol, row);
|
int64_t ekey = *(int64_t*)colDataGetData(pEndTsCol, row);
|
||||||
int64_t groupId = *(int64_t*)colDataGetData(pGidCol, row);
|
int64_t groupId = *(int64_t*)colDataGetData(pGidCol, row);
|
||||||
|
|
||||||
char* name = NULL;
|
char* name = NULL;
|
||||||
char* pName = NULL;
|
char* originName = NULL;
|
||||||
void* varTbName = NULL;
|
void* varTbName = NULL;
|
||||||
tbName[0] = '\0';
|
|
||||||
if (!colDataIsNull(pTbNameCol, totalRows, row, NULL)) {
|
if (!colDataIsNull(pTbNameCol, totalRows, row, NULL)) {
|
||||||
varTbName = colDataGetVarData(pTbNameCol, row);
|
varTbName = colDataGetVarData(pTbNameCol, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (varTbName != NULL && varTbName != (void*)-1) {
|
if (varTbName != NULL && varTbName != (void*)-1) {
|
||||||
name = varDataVal(varTbName);
|
name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN);
|
||||||
|
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
||||||
} else if (stbFullName) {
|
} else if (stbFullName) {
|
||||||
pName = buildCtbNameByGroupId(stbFullName, groupId);
|
name = buildCtbNameByGroupId(stbFullName, groupId);
|
||||||
name = pName;
|
|
||||||
} else {
|
} else {
|
||||||
if (metaGetTableNameByUid(pTq->pVnode, groupId, tbName) == 0) {
|
originName = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE);
|
||||||
name = varDataVal(tbName);
|
if (metaGetTableNameByUid(pTq->pVnode, groupId, originName) == 0) {
|
||||||
|
name = varDataVal(originName);
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -90,17 +89,19 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("s-task:%s build delete msg groupId:%" PRId64 ", name:%s, skey:%" PRId64 " ekey:%" PRId64, pIdStr, groupId,
|
tqDebug("s-task:%s build delete msg groupId:%" PRId64 ", name:%s, skey:%" PRId64 " ekey:%" PRId64,
|
||||||
name, skey, ekey);
|
pIdStr, groupId, name, skey, ekey);
|
||||||
|
|
||||||
SSingleDeleteReq req = {.startTs = skey, .endTs = ekey};
|
SSingleDeleteReq req = { .startTs = skey, .endTs = ekey};
|
||||||
strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN - 1);
|
strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN - 1);
|
||||||
if (pName) taosMemoryFree(pName);
|
|
||||||
|
if (originName) name = originName;
|
||||||
|
taosMemoryFree(name);
|
||||||
|
|
||||||
taosArrayPush(deleteReq->deleteReqs, &req);
|
taosArrayPush(deleteReq->deleteReqs, &req);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t encodeCreateChildTableForRPC(SVCreateTbBatchReq* pReqs, int32_t vgId, void** pBuf, int32_t* contLen) {
|
static int32_t encodeCreateChildTableForRPC(SVCreateTbBatchReq* pReqs, int32_t vgId, void** pBuf, int32_t* contLen) {
|
||||||
|
|
Loading…
Reference in New Issue