diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 874a022a7104860fce8f6389bcc933b36a2fef22..3c1d4f453c2f8be75b9eddfaf02f30b0b25f6ab8 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -5522,6 +5522,11 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in varDataSetLen(tagData, outLen); tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagVal, true); }else if(item->type == cJSON_Number){ + if(!isfinite(item->valuedouble)){ + tscError("json value is invalidate"); + retCode = tscSQLSyntaxErrMsg(errMsg, "json value number is illegal", NULL); + goto end; + } char tagVal[LONG_BYTES + CHAR_BYTES] = {0}; *tagVal = jsonType2DbType(item->valuedouble, item->type); // type char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); diff --git a/tests/develop-test/0-management/3-tag/json_tag.py b/tests/develop-test/0-management/3-tag/json_tag.py index dc7affe870f4462526aa1095311278d280abe77f..b6a15ca770ea7e4885973a03bfc8e3bd08c3f54d 100644 --- a/tests/develop-test/0-management/3-tag/json_tag.py +++ b/tests/develop-test/0-management/3-tag/json_tag.py @@ -75,6 +75,10 @@ class TDTestCase: tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')") tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"试试\":\"fff\"}')") + # test invalidate json value, value number can not be inf,nan TD-12166 + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"k\":1.8e308}')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"k\":-1.8e308}')") + #test length limit char1= ''.join(['abcd']*64) char3= ''.join(['abcd']*1022)