Skip to content

Commit

Permalink
Merge pull request #2251 from taosdata/hotfix/fix-compiler-error
Browse files Browse the repository at this point in the history
fix compile error under higher version of gcc
  • Loading branch information
guanshengliang committed Jun 12, 2020
2 parents a4018dc + c10730f commit e681737
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/client/src/tscLocal.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ static void tscProcessCurrentUser(SSqlObj *pSql) {
pExpr->resType = TSDB_DATA_TYPE_BINARY;

char* vx = calloc(1, pExpr->resBytes);
STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, sizeof(pSql->pTscObj->user));
size_t size = sizeof(pSql->pTscObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, size);

tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes);
free(vx);
Expand Down
5 changes: 3 additions & 2 deletions src/client/src/tscServer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1708,8 +1708,9 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {

for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, i);
tstrncpy(pMsg, pTableMetaInfo->name, sizeof(pTableMetaInfo->name));
pMsg += sizeof(pTableMetaInfo->name);
size_t size = sizeof(pTableMetaInfo->name);
tstrncpy(pMsg, pTableMetaInfo->name, size);
pMsg += size;
}

pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP;
Expand Down
18 changes: 12 additions & 6 deletions src/mnode/src/mnodeProfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,14 @@ static int32_t mnodeRetrieveConns(SShowObj *pShow, char *data, int32_t rows, voi
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user));
size_t size = sizeof(pConnObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, size);
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, sizeof(ipStr));
size = sizeof(ipStr);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, size);
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
Expand Down Expand Up @@ -358,12 +360,14 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user));
size_t size = sizeof(pConnObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, size);
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, sizeof(ipStr));
size = sizeof(ipStr);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, size);
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
Expand Down Expand Up @@ -479,12 +483,14 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user));
size_t size = sizeof(pConnObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, size);
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, sizeof(ipStr));
size = sizeof(ipStr);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, size);
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
Expand Down
3 changes: 2 additions & 1 deletion src/mnode/src/mnodeTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,8 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_OUT_OF_MEMORY;
}

tstrncpy(pCreateMsg->tableId, pInfo->tableId, sizeof(pInfo->tableId));
size_t size = sizeof(pInfo->tableId);
tstrncpy(pCreateMsg->tableId, pInfo->tableId, size);
tstrncpy(pCreateMsg->db, pMsg->pDb->name, sizeof(pCreateMsg->db));
pCreateMsg->igExists = 1;
pCreateMsg->getMeta = 1;
Expand Down
3 changes: 2 additions & 1 deletion src/mnode/src/mnodeUser.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi
cols = 0;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->user, sizeof(pUser->user));
size_t size = sizeof(pUser->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->user, size);
cols++;

pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/http/src/httpAuth.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ bool httpParseTaosdAuthToken(HttpContext *pContext, char *token, int len) {

bool httpGenTaosdAuthToken(HttpContext *pContext, char *token, int maxLen) {
char buffer[sizeof(pContext->user) + sizeof(pContext->pass)] = {0};
tstrncpy(buffer, pContext->user, sizeof(pContext->user));
tstrncpy(buffer + sizeof(pContext->user), pContext->pass, sizeof(pContext->pass));
size_t size = sizeof(pContext->user);
tstrncpy(buffer, pContext->user, size);
size = sizeof(pContext->pass);
tstrncpy(buffer + sizeof(pContext->user), pContext->pass, size);

char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_PASSWORD_LEN);
char *base64 = base64_encode((const unsigned char *)encrypt, TSDB_USER_LEN + TSDB_PASSWORD_LEN);
Expand Down

0 comments on commit e681737

Please sign in to comment.