Merge pull request #28013 from taosdata/fix/TD-32122-3.0

fix: column length check for stmt insert
This commit is contained in:
Hongze Cheng 2024-09-23 16:22:55 +08:00 committed by GitHub
commit 349a66b8a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -481,6 +481,10 @@ int32_t tRowBuildFromBind(SBindInfo *infos, int32_t numOfInfos, bool infoSorted,
};
if (IS_VAR_DATA_TYPE(infos[iInfo].type)) {
value.nData = infos[iInfo].bind->length[iRow];
if (value.nData > pTSchema->columns[iInfo].bytes - VARSTR_HEADER_SIZE) {
code = TSDB_CODE_INVALID_PARA;
goto _exit;
}
value.pData = (uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bind->buffer_length * iRow;
} else {
(void)memcpy(&value.val, (uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bind->buffer_length * iRow,
@ -3279,6 +3283,10 @@ int32_t tRowBuildFromBind2(SBindInfo2 *infos, int32_t numOfInfos, bool infoSorte
int32_t length = infos[iInfo].bind->length[iRow];
uint8_t **data = &((uint8_t **)TARRAY_DATA(bufArray))[iInfo];
value.nData = length;
if (value.nData > pTSchema->columns[iInfo].bytes - VARSTR_HEADER_SIZE) {
code = TSDB_CODE_INVALID_PARA;
goto _exit;
}
value.pData = *data;
*data += length;
// value.pData = (uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bind->buffer_length * iRow;