Merge pull request #12637 from taosdata/fix/invalid_read
fix: avoid invalid read/write
This commit is contained in:
commit
1c7df11df1
|
@ -213,8 +213,9 @@ int32_t sdbGetRawBinary(SSdbRaw *pRaw, int32_t dataPos, char *pVal, int32_t valL
|
||||||
terrno = TSDB_CODE_SDB_INVALID_DATA_LEN;
|
terrno = TSDB_CODE_SDB_INVALID_DATA_LEN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (pVal != NULL) {
|
||||||
memcpy(pVal, pRaw->pData + dataPos, valLen);
|
memcpy(pVal, pRaw->pData + dataPos, valLen);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,17 +473,16 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTempR
|
||||||
|
|
||||||
int32_t sz = 0;
|
int32_t sz = 0;
|
||||||
char* ch = (char*)fstSliceData(s, &sz);
|
char* ch = (char*)fstSliceData(s, &sz);
|
||||||
// char* tmp = taosMemoryCalloc(1, sz + 1);
|
char* tmp = taosMemoryCalloc(1, sz + 1);
|
||||||
// memcpy(tmp, ch, sz);
|
memcpy(tmp, ch, sz);
|
||||||
|
|
||||||
if (0 != strncmp(ch, p, skip)) {
|
if (0 != strncmp(tmp, p, skip)) {
|
||||||
swsResultDestroy(rt);
|
swsResultDestroy(rt);
|
||||||
// taosMemoryFree(tmp);
|
taosMemoryFree(tmp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TExeCond cond = cmpFn(ch + skip, tem->colVal, INDEX_TYPE_GET_TYPE(tem->colType));
|
TExeCond cond = cmpFn(tmp + skip, tem->colVal, INDEX_TYPE_GET_TYPE(tem->colType));
|
||||||
|
|
||||||
if (MATCH == cond) {
|
if (MATCH == cond) {
|
||||||
tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total);
|
tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total);
|
||||||
} else if (CONTINUE == cond) {
|
} else if (CONTINUE == cond) {
|
||||||
|
@ -491,7 +490,7 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTempR
|
||||||
swsResultDestroy(rt);
|
swsResultDestroy(rt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// taosMemoryFree(tmp);
|
taosMemoryFree(tmp);
|
||||||
swsResultDestroy(rt);
|
swsResultDestroy(rt);
|
||||||
}
|
}
|
||||||
streamWithStateDestroy(st);
|
streamWithStateDestroy(st);
|
||||||
|
|
|
@ -578,3 +578,40 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_FLOAT) {
|
||||||
EXPECT_EQ(1000, taosArrayGetSize(res));
|
EXPECT_EQ(1000, taosArrayGetSize(res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TEST_F(JsonEnv, testWriteJsonTfileAndCache_DOUBLE) {
|
||||||
|
{
|
||||||
|
double val = 10.0;
|
||||||
|
std::string colName("test1");
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
WriteData(index, colName, TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
double val = 2.0;
|
||||||
|
std::string colName("test1");
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
WriteData(index, colName, TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), i + 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SArray* res = NULL;
|
||||||
|
std::string colName("test1");
|
||||||
|
double val = 1.9;
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_GREATER_EQUAL, &res);
|
||||||
|
EXPECT_EQ(2000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SArray* res = NULL;
|
||||||
|
std::string colName("test1");
|
||||||
|
double val = 2.1;
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_GREATER_EQUAL, &res);
|
||||||
|
EXPECT_EQ(1000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::string colName("test1");
|
||||||
|
SArray* res = NULL;
|
||||||
|
double val = 2.1;
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_GREATER_EQUAL, &res);
|
||||||
|
EXPECT_EQ(1000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -924,8 +924,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
||||||
arg->param1 = pMsg;
|
arg->param1 = pMsg;
|
||||||
arg->param2 = pThrd;
|
arg->param2 = pThrd;
|
||||||
transDQSched(pThrd->delayQueue, doDelayTask, arg, TRANS_RETRY_INTERVAL);
|
transDQSched(pThrd->delayQueue, doDelayTask, arg, TRANS_RETRY_INTERVAL);
|
||||||
|
cliDestroyConn(pConn, true);
|
||||||
cliDestroy((uv_handle_t*)pConn->stream);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) {
|
} else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) {
|
||||||
|
|
Loading…
Reference in New Issue