Merge pull request #18389 from taosdata/fix/TS-2145
enh: add stmt tag length validation
This commit is contained in:
commit
db672f50e3
|
@ -47,6 +47,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
||||||
TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen) {
|
TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen) {
|
||||||
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags;
|
SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags;
|
||||||
if (NULL == tags) {
|
if (NULL == tags) {
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
@ -59,10 +60,10 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
||||||
|
|
||||||
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||||
if (!tagName) {
|
if (!tagName) {
|
||||||
return buildInvalidOperationMsg(&pBuf, "out of memory");
|
code = buildInvalidOperationMsg(&pBuf, "out of memory");
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta);
|
SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta);
|
||||||
|
|
||||||
bool isJson = false;
|
bool isJson = false;
|
||||||
|
@ -77,6 +78,10 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
||||||
int32_t colLen = pTagSchema->bytes;
|
int32_t colLen = pTagSchema->bytes;
|
||||||
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
||||||
colLen = bind[c].length[0];
|
colLen = bind[c].length[0];
|
||||||
|
if ((colLen + VARSTR_HEADER_SIZE) > pTagSchema->bytes) {
|
||||||
|
code = buildInvalidOperationMsg(&pBuf, "tag length is too big");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taosArrayPush(tagName, pTagSchema->name);
|
taosArrayPush(tagName, pTagSchema->name);
|
||||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
|
Loading…
Reference in New Issue