[td-3277]<fix>: fix the taosd crash caused by fetching the too long binary data in tags.
This commit is contained in:
parent
2c272604f4
commit
2d2316eeec
|
@ -2913,7 +2913,9 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type);
|
int32_t maxLen = bytes - VARSTR_HEADER_SIZE;
|
||||||
|
int32_t len = (varDataLen(val) > maxLen)? maxLen:varDataLen(val);
|
||||||
|
tVariantCreateFromBinary(tag, varDataVal(val), len, type);
|
||||||
} else {
|
} else {
|
||||||
if (isNull(val, type)) {
|
if (isNull(val, type)) {
|
||||||
tag->nType = TSDB_DATA_TYPE_NULL;
|
tag->nType = TSDB_DATA_TYPE_NULL;
|
||||||
|
@ -7070,8 +7072,15 @@ static void doSetTagValueToResultBuf(char* output, const char* val, int16_t type
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
memcpy(output, val, varDataTLen(val));
|
// Binary data overflows for sort of unknown reasons. Let trim the overflow data
|
||||||
|
if (varDataTLen(val) > bytes) {
|
||||||
|
int32_t len = bytes;
|
||||||
|
memcpy(varDataVal(output), varDataVal(val), len);
|
||||||
|
varDataSetLen(output, len);
|
||||||
|
} else {
|
||||||
|
varDataCopy(output, val);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(output, val, bytes);
|
memcpy(output, val, bytes);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue