提交 c304b179 编写于 作者: H huili

[validate table name when insert]

上级 95dc6b41
...@@ -724,6 +724,19 @@ static int32_t tscParseSqlForCreateTableOnDemand(char** sqlstr, SSqlObj* pSql) { ...@@ -724,6 +724,19 @@ static int32_t tscParseSqlForCreateTableOnDemand(char** sqlstr, SSqlObj* pSql) {
return code; return code;
} }
int validateTableName(char* tblName, int len)
{
char buf[TSDB_METER_ID_LEN] = {0};
memcpy(buf, tblName, len);
SSQLToken token = {len, TK_ID, buf};
tSQLGetToken(buf, &token.type);
return tscValidateName(&token);
}
/** /**
* usage: insert into table1 values() () table2 values()() * usage: insert into table1 values() () table2 values()()
* *
...@@ -774,6 +787,16 @@ int tsParseInsertStatement(SSqlCmd* pCmd, char* str, char* acct, char* db, SSqlO ...@@ -774,6 +787,16 @@ int tsParseInsertStatement(SSqlCmd* pCmd, char* str, char* acct, char* db, SSqlO
} }
} }
/*
* Check the validity of the table name
*
*/
if (validateTableName(id, idlen) != TSDB_CODE_SUCCESS) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "table name is invalid");
goto _error_clean;
}
SSQLToken token = {idlen, TK_ID, id}; SSQLToken token = {idlen, TK_ID, id};
if ((code = setMeterID(pSql, &token)) != TSDB_CODE_SUCCESS) { if ((code = setMeterID(pSql, &token)) != TSDB_CODE_SUCCESS) {
goto _error_clean; goto _error_clean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册