提交 7f123214 编写于 作者: B Bomin Zhang

TD-459: TSDB_USER_LEN

上级 b81f7158
...@@ -279,7 +279,7 @@ static void tscProcessCurrentUser(SSqlObj *pSql) { ...@@ -279,7 +279,7 @@ static void tscProcessCurrentUser(SSqlObj *pSql) {
pExpr->resType = TSDB_DATA_TYPE_BINARY; pExpr->resType = TSDB_DATA_TYPE_BINARY;
char* vx = calloc(1, pExpr->resBytes); char* vx = calloc(1, pExpr->resBytes);
STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, TSDB_USER_LEN); STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, sizeof(pSql->pTscObj->user));
tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes);
free(vx); free(vx);
......
...@@ -232,7 +232,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -232,7 +232,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pzName->n = strdequote(pzName->z); pzName->n = strdequote(pzName->z);
strncpy(pTableMetaInfo->name, pzName->z, pzName->n); strncpy(pTableMetaInfo->name, pzName->z, pzName->n);
} else { // drop user } else { // drop user
if (pzName->n > TSDB_USER_LEN) { if (pzName->n >= TSDB_USER_LEN) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
...@@ -317,7 +317,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -317,7 +317,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
if (pName->n > TSDB_USER_LEN) { if (pName->n >= TSDB_USER_LEN) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
...@@ -401,7 +401,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -401,7 +401,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pName = &pUser->user; SSQLToken* pName = &pUser->user;
SSQLToken* pPwd = &pUser->passwd; SSQLToken* pPwd = &pUser->passwd;
if (pName->n > TSDB_USER_LEN) { if (pName->n >= TSDB_USER_LEN) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
......
...@@ -718,7 +718,7 @@ static void doInitGlobalConfig() { ...@@ -718,7 +718,7 @@ static void doInitGlobalConfig() {
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0; cfg.minValue = 0;
cfg.maxValue = 0; cfg.maxValue = 0;
cfg.ptrLength = TSDB_USER_LEN; cfg.ptrLength = TSDB_USER_LEN - 1;
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
......
...@@ -147,7 +147,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char ...@@ -147,7 +147,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char
if (code != TSDB_CODE_RPC_NOT_READY) return code; if (code != TSDB_CODE_RPC_NOT_READY) return code;
SDMAuthMsg *pMsg = rpcMallocCont(sizeof(SDMAuthMsg)); SDMAuthMsg *pMsg = rpcMallocCont(sizeof(SDMAuthMsg));
tstrncpy(pMsg->user, user, TSDB_USER_LEN); tstrncpy(pMsg->user, user, sizeof(pMsg->user));
SRpcMsg rpcMsg = {0}; SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pMsg; rpcMsg.pCont = pMsg;
......
...@@ -321,18 +321,18 @@ typedef struct { ...@@ -321,18 +321,18 @@ typedef struct {
} SAcctCfg; } SAcctCfg;
typedef struct { typedef struct {
char user[TSDB_USER_LEN + 1]; char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN + 1]; char pass[TSDB_KEY_LEN];
SAcctCfg cfg; SAcctCfg cfg;
} SCMCreateAcctMsg, SCMAlterAcctMsg; } SCMCreateAcctMsg, SCMAlterAcctMsg;
typedef struct { typedef struct {
char user[TSDB_USER_LEN + 1]; char user[TSDB_USER_LEN];
} SCMDropUserMsg, SCMDropAcctMsg; } SCMDropUserMsg, SCMDropAcctMsg;
typedef struct { typedef struct {
char user[TSDB_USER_LEN + 1]; char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN + 1]; char pass[TSDB_KEY_LEN];
int8_t privilege; int8_t privilege;
int8_t flag; int8_t flag;
} SCMCreateUserMsg, SCMAlterUserMsg; } SCMCreateUserMsg, SCMAlterUserMsg;
...@@ -501,7 +501,7 @@ typedef struct { ...@@ -501,7 +501,7 @@ typedef struct {
} SVnodeLoad; } SVnodeLoad;
typedef struct { typedef struct {
char acct[TSDB_USER_LEN + 1]; char acct[TSDB_USER_LEN];
char db[TSDB_DB_NAME_LEN]; char db[TSDB_DB_NAME_LEN];
int32_t cacheBlockSize; //MB int32_t cacheBlockSize; //MB
int32_t totalBlocks; int32_t totalBlocks;
...@@ -750,7 +750,7 @@ typedef struct { ...@@ -750,7 +750,7 @@ typedef struct {
} SMDAlterStreamMsg; } SMDAlterStreamMsg;
typedef struct { typedef struct {
char user[TSDB_USER_LEN + 1]; char user[TSDB_USER_LEN];
char spi; char spi;
char encrypt; char encrypt;
char secret[TSDB_KEY_LEN + 1]; char secret[TSDB_KEY_LEN + 1];
......
...@@ -155,7 +155,7 @@ typedef struct { ...@@ -155,7 +155,7 @@ typedef struct {
typedef struct SDbObj { typedef struct SDbObj {
char name[TSDB_DB_NAME_LEN]; char name[TSDB_DB_NAME_LEN];
char acct[TSDB_USER_LEN + 1]; char acct[TSDB_USER_LEN];
int64_t createdTime; int64_t createdTime;
int32_t cfgVersion; int32_t cfgVersion;
SDbCfg cfg; SDbCfg cfg;
...@@ -172,9 +172,9 @@ typedef struct SDbObj { ...@@ -172,9 +172,9 @@ typedef struct SDbObj {
} SDbObj; } SDbObj;
typedef struct SUserObj { typedef struct SUserObj {
char user[TSDB_USER_LEN + 1]; char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN + 1]; char pass[TSDB_KEY_LEN];
char acct[TSDB_USER_LEN + 1]; char acct[TSDB_USER_LEN];
int64_t createdTime; int64_t createdTime;
int8_t superAuth; int8_t superAuth;
int8_t writeAuth; int8_t writeAuth;
...@@ -203,7 +203,7 @@ typedef struct { ...@@ -203,7 +203,7 @@ typedef struct {
} SAcctInfo; } SAcctInfo;
typedef struct SAcctObj { typedef struct SAcctObj {
char user[TSDB_USER_LEN + 1]; char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN + 1]; char pass[TSDB_KEY_LEN + 1];
SAcctCfg cfg; SAcctCfg cfg;
int32_t acctId; int32_t acctId;
......
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
#include "mnodeDef.h" #include "mnodeDef.h"
typedef struct { typedef struct {
char user[TSDB_USER_LEN + 1]; char user[TSDB_USER_LEN];
int8_t killed; int8_t killed;
uint16_t port; uint16_t port;
uint32_t ip; uint32_t ip;
......
...@@ -97,7 +97,7 @@ SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) { ...@@ -97,7 +97,7 @@ SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) {
.connId = connId, .connId = connId,
.stime = taosGetTimestampMs() .stime = taosGetTimestampMs()
}; };
tstrncpy(connObj.user, user, TSDB_USER_LEN); tstrncpy(connObj.user, user, sizeof(connObj.user));
char key[10]; char key[10];
sprintf(key, "%u", connId); sprintf(key, "%u", connId);
...@@ -235,7 +235,7 @@ static int32_t mnodeRetrieveConns(SShowObj *pShow, char *data, int32_t rows, voi ...@@ -235,7 +235,7 @@ static int32_t mnodeRetrieveConns(SShowObj *pShow, char *data, int32_t rows, voi
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, TSDB_USER_LEN); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user));
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
...@@ -358,7 +358,7 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v ...@@ -358,7 +358,7 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, TSDB_USER_LEN); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user));
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
...@@ -479,7 +479,7 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v ...@@ -479,7 +479,7 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, TSDB_USER_LEN); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user));
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
......
...@@ -315,7 +315,7 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi ...@@ -315,7 +315,7 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi
cols = 0; cols = 0;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->user, TSDB_USER_LEN); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->user, sizeof(pUser->user));
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
...@@ -336,7 +336,7 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi ...@@ -336,7 +336,7 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->acct, TSDB_USER_LEN); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->acct, sizeof(pUser->user));
cols++; cols++;
numOfRows++; numOfRows++;
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
#define HTTP_COMPRESS_IDENTITY 0 #define HTTP_COMPRESS_IDENTITY 0
#define HTTP_COMPRESS_GZIP 2 #define HTTP_COMPRESS_GZIP 2
#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN * 2 + 1) #define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_PASSWORD_LEN)
typedef enum { typedef enum {
HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY,
...@@ -84,7 +84,7 @@ typedef struct { ...@@ -84,7 +84,7 @@ typedef struct {
int expire; int expire;
int access; int access;
void *taos; void *taos;
char id[HTTP_SESSION_ID_LEN + 1]; char id[HTTP_SESSION_ID_LEN];
} HttpSession; } HttpSession;
typedef enum { typedef enum {
......
...@@ -48,7 +48,7 @@ void gcInitHandle(HttpServer* pServer) { httpAddMethod(pServer, &gcDecodeMethod) ...@@ -48,7 +48,7 @@ void gcInitHandle(HttpServer* pServer) { httpAddMethod(pServer, &gcDecodeMethod)
bool gcGetUserFromUrl(HttpContext* pContext) { bool gcGetUserFromUrl(HttpContext* pContext) {
HttpParser* pParser = &pContext->parser; HttpParser* pParser = &pContext->parser;
if (pParser->path[GC_USER_URL_POS].len > TSDB_USER_LEN - 1 || pParser->path[GC_USER_URL_POS].len <= 0) { if (pParser->path[GC_USER_URL_POS].len >= TSDB_USER_LEN || pParser->path[GC_USER_URL_POS].len <= 0) {
return false; return false;
} }
......
...@@ -101,7 +101,7 @@ bool httpParseTaosdAuthToken(HttpContext *pContext, char *token, int len) { ...@@ -101,7 +101,7 @@ bool httpParseTaosdAuthToken(HttpContext *pContext, char *token, int len) {
bool httpGenTaosdAuthToken(HttpContext *pContext, char *token, int maxLen) { bool httpGenTaosdAuthToken(HttpContext *pContext, char *token, int maxLen) {
char buffer[TSDB_USER_LEN + TSDB_PASSWORD_LEN] = {0}; char buffer[TSDB_USER_LEN + TSDB_PASSWORD_LEN] = {0};
strncpy(buffer, pContext->user, TSDB_USER_LEN); strncpy(buffer, pContext->user, sizeof(pContext->user));
strncpy(buffer + TSDB_USER_LEN, pContext->pass, TSDB_PASSWORD_LEN); strncpy(buffer + TSDB_USER_LEN, pContext->pass, TSDB_PASSWORD_LEN);
char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_PASSWORD_LEN); char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_PASSWORD_LEN);
......
...@@ -61,7 +61,7 @@ void restInitHandle(HttpServer* pServer) { ...@@ -61,7 +61,7 @@ void restInitHandle(HttpServer* pServer) {
bool restGetUserFromUrl(HttpContext* pContext) { bool restGetUserFromUrl(HttpContext* pContext) {
HttpParser* pParser = &pContext->parser; HttpParser* pParser = &pContext->parser;
if (pParser->path[REST_USER_URL_POS].len > TSDB_USER_LEN - 1 || pParser->path[REST_USER_URL_POS].len <= 0) { if (pParser->path[REST_USER_URL_POS].len >= TSDB_USER_LEN || pParser->path[REST_USER_URL_POS].len <= 0) {
return false; return false;
} }
......
...@@ -306,11 +306,11 @@ void tgCleanupHandle() { ...@@ -306,11 +306,11 @@ void tgCleanupHandle() {
bool tgGetUserFromUrl(HttpContext *pContext) { bool tgGetUserFromUrl(HttpContext *pContext) {
HttpParser *pParser = &pContext->parser; HttpParser *pParser = &pContext->parser;
if (pParser->path[TG_USER_URL_POS].len > TSDB_USER_LEN - 1 || pParser->path[TG_USER_URL_POS].len <= 0) { if (pParser->path[TG_USER_URL_POS].len >= TSDB_USER_LEN || pParser->path[TG_USER_URL_POS].len <= 0) {
return false; return false;
} }
tstrncpy(pContext->user, pParser->path[TG_USER_URL_POS].pos, TSDB_USER_LEN); tstrncpy(pContext->user, pParser->path[TG_USER_URL_POS].pos, sizeof(pContext->user));
return true; return true;
} }
......
...@@ -175,7 +175,7 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) { ...@@ -175,7 +175,7 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) {
", totalConns smallint, maxConns smallint" ", totalConns smallint, maxConns smallint"
", accessState smallint" ", accessState smallint"
") tags (acctId binary(%d))", ") tags (acctId binary(%d))",
tsMonitorDbName, TSDB_USER_LEN + 1); tsMonitorDbName, TSDB_USER_LEN);
} else if (cmd == MONITOR_CMD_CREATE_TB_ACCT_ROOT) { } else if (cmd == MONITOR_CMD_CREATE_TB_ACCT_ROOT) {
snprintf(sql, SQL_LENGTH, "create table if not exists %s.acct_%s using %s.acct tags('%s')", tsMonitorDbName, "root", snprintf(sql, SQL_LENGTH, "create table if not exists %s.acct_%s using %s.acct tags('%s')", tsMonitorDbName, "root",
tsMonitorDbName, "root"); tsMonitorDbName, "root");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册