Merge pull request #27171 from taosdata/fix/TD-31002-3.0

fix: add size limit for create table batch msg
This commit is contained in:
Hongze Cheng 2024-08-13 18:29:47 +08:00 committed by GitHub
commit 6f014d1ca1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -13177,6 +13177,10 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch
if (TSDB_CODE_SUCCESS != ret) {
return ret;
}
if (tlen >= TSDB_MAX_MSG_SIZE - sizeof(SMsgHead)) {
return TSDB_CODE_INVALID_MSG_LEN;
}
tlen += sizeof(SMsgHead);
void* buf = taosMemoryMalloc(tlen);
if (NULL == buf) {
@ -14014,6 +14018,7 @@ int32_t serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap, SArray** pOut
code = serializeVgroupCreateTableBatch(pTbBatch, pBufArray);
if (TSDB_CODE_SUCCESS != code) {
qError("failed to serialize create table batch msg, since:%s", tstrerror(code));
taosHashCancelIterate(pVgroupHashmap, pTbBatch);
break;
}
@ -14091,6 +14096,9 @@ static int32_t rewriteCreateTableFromFile(STranslateContext* pCxt, SQuery* pQuer
code = serializeVgroupsCreateTableBatch(pModifyStmt->pVgroupsHashObj, &pBufArray);
taosHashClear(pModifyStmt->pVgroupsHashObj);
if (TSDB_CODE_SUCCESS != code) {
if (TSDB_CODE_INVALID_MSG_LEN == code) {
qError("maxInsertBatchRows may need to be reduced, current:%d", tsMaxInsertBatchRows);
}
taosHashCleanup(pModifyStmt->pVgroupsHashObj);
return code;
}