enhance: add length verification

This commit is contained in:
slzhou 2023-12-20 16:20:43 +08:00
parent 9ebca3eaff
commit d6445d2d5b
1 changed files with 8 additions and 1 deletions

View File

@ -3222,7 +3222,7 @@ _error:
static int32_t saveBlockRowToBuf(STableMergeScanInfo* pInfo, SSDataBlock* pBlock, int32_t rowIdx, int32_t* pPageId, int32_t* pOffset, int32_t* pLength) { static int32_t saveBlockRowToBuf(STableMergeScanInfo* pInfo, SSDataBlock* pBlock, int32_t rowIdx, int32_t* pPageId, int32_t* pOffset, int32_t* pLength) {
SDiskbasedBuf* pResultBuf = pInfo->sortRowIdInfo.pExtSrcRowsBuf; SDiskbasedBuf* pResultBuf = pInfo->sortRowIdInfo.pExtSrcRowsBuf;
int32_t rowBytes = blockDataGetRowSize(pBlock) + taosArrayGetSize(pBlock->pDataBlock); int32_t rowBytes = blockDataGetRowSize(pBlock) + taosArrayGetSize(pBlock->pDataBlock) + sizeof(int32_t);
SFilePage* pFilePage = NULL; SFilePage* pFilePage = NULL;
@ -3291,6 +3291,8 @@ static int32_t saveBlockRowToBuf(STableMergeScanInfo* pInfo, SSDataBlock* pBlock
pStart += bytes; pStart += bytes;
} }
} }
*(int32_t*)pStart = (char*)pStart - (char*)buf;
pStart += sizeof(int32_t);
*pLength = (int32_t)(pStart - (char*)buf); *pLength = (int32_t)(pStart - (char*)buf);
pFilePage->num += (*pLength); pFilePage->num += (*pLength);
setBufPageDirty(pFilePage, true); setBufPageDirty(pFilePage, true);
@ -3356,6 +3358,11 @@ static void appendOneRowIdRowToDataBlock(STableMergeScanInfo* pInfo, SSDataBlock
colDataSetNULL(pColInfo, pBlock->info.rows); colDataSetNULL(pColInfo, pBlock->info.rows);
} }
} }
if (*(int32_t*)pStart != pStart-buf) {
qError("table merge scan row buf deserialization. length error %d != %d ", *(int32_t*)pStart, (int32_t)(pStart-buf));
};
releaseBufPage(pInfo->sortRowIdInfo.pExtSrcRowsBuf, page); releaseBufPage(pInfo->sortRowIdInfo.pExtSrcRowsBuf, page);
pBlock->info.dataLoad = 1; pBlock->info.dataLoad = 1;