diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 9745597d990efed6729b01944a57ebffb5c690c8..38d32cc025e6596b7b0368f75813536527e7069e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -902,13 +902,17 @@ int32_t parseSlidingClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQu int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableName, SSqlObj* pSql) { const char* msg1 = "name too long"; + const char* msg2 = "acctId too long"; SSqlCmd* pCmd = &pSql->cmd; int32_t code = TSDB_CODE_SUCCESS; if (hasSpecifyDB(pTableName)) { // db has been specified in sql string so we ignore current db path - tNameSetAcctId(&pTableMetaInfo->name, getAccountId(pSql)); - + code = tNameSetAcctId(&pTableMetaInfo->name, getAccountId(pSql)); + if (code != 0) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + char name[TSDB_TABLE_FNAME_LEN] = {0}; strncpy(name, pTableName->z, pTableName->n); diff --git a/src/common/src/tname.c b/src/common/src/tname.c index 5c49e2e1026995e8d3924ba6d63a0c0b504c7439..bbb0a8c082ab1aee27a8caf60abde68f25ce0cbf 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -367,6 +367,9 @@ int32_t tNameSetAcctId(SName* dst, const char* acct) { } tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); + + assert(strlen(dst->acctId) > 0); + return 0; } @@ -383,12 +386,14 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) { int32_t len = (int32_t)(p - str); // too long account id or too long db name - if (len >= tListLen(dst->acctId) || len == 0) { + if ((len >= tListLen(dst->acctId)) || (len <= 0)) { return -1; } memcpy (dst->acctId, str, len); dst->acctId[len] = 0; + + assert(strlen(dst->acctId) > 0); } if ((type & T_NAME_DB) == T_NAME_DB) { @@ -404,7 +409,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) { } // too long account id or too long db name - if (len >= tListLen(dst->dbname) || len == 0) { + if ((len >= tListLen(dst->dbname)) || (len <= 0)) { return -1; } @@ -419,7 +424,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) { int32_t len = (int32_t) strlen(start); // too long account id or too long db name - if (len >= tListLen(dst->tname) || len == 0) { + if ((len >= tListLen(dst->tname)) || (len <= 0)) { return -1; }