TD-459: fix coverity issues
290707 288014 290195 290193 290186 288205 288005 286989 286970 286967 278634 268232 268153 268075 267950 267940 267724 267855 267732
This commit is contained in:
parent
88f0d2c836
commit
6d717a2b57
|
@ -5420,7 +5420,7 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
|
|||
tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, false);
|
||||
|
||||
const char* name = (pExprList->a[0].aliasName != NULL)? pExprList->a[0].aliasName:functionsInfo[index].name;
|
||||
strncpy(pExpr1->aliasName, name, tListLen(pExpr1->aliasName));
|
||||
tstrncpy(pExpr1->aliasName, name, tListLen(pExpr1->aliasName));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1018,7 +1018,7 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
|
||||
SCMDropDnodeMsg *pDrop = (SCMDropDnodeMsg *)pCmd->payload;
|
||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||
strcpy(pDrop->ep, pTableMetaInfo->name);
|
||||
tstrncpy(pDrop->ep, pTableMetaInfo->name, sizeof(pDrop->ep));
|
||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DNODE;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1036,7 +1036,7 @@ int32_t tscBuildDropUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
|
||||
SCMDropUserMsg *pDropMsg = (SCMDropUserMsg*)pCmd->payload;
|
||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||
strcpy(pDropMsg->user, pTableMetaInfo->name);
|
||||
tstrncpy(pDropMsg->user, pTableMetaInfo->name, sizeof(pDropMsg->user));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1091,9 +1091,9 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||
size_t nameLen = strlen(pTableMetaInfo->name);
|
||||
if (nameLen > 0) {
|
||||
strcpy(pShowMsg->db, pTableMetaInfo->name); // prefix is set here
|
||||
tstrncpy(pShowMsg->db, pTableMetaInfo->name, sizeof(pShowMsg->db)); // prefix is set here
|
||||
} else {
|
||||
strcpy(pShowMsg->db, pObj->db);
|
||||
tstrncpy(pShowMsg->db, pObj->db, sizeof(pShowMsg->db));
|
||||
}
|
||||
|
||||
SShowInfo *pShowInfo = &pInfo->pDCLInfo->showOpt;
|
||||
|
@ -1300,7 +1300,7 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
|
||||
SCMAlterDbMsg *pAlterDbMsg = (SCMAlterDbMsg*)pCmd->payload;
|
||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||
strcpy(pAlterDbMsg->db, pTableMetaInfo->name);
|
||||
tstrncpy(pAlterDbMsg->db, pTableMetaInfo->name, sizeof(pAlterDbMsg->db));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -593,7 +593,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
|
|||
dataBuf->size = startOffset;
|
||||
dataBuf->tsSource = -1;
|
||||
|
||||
strncpy(dataBuf->tableId, name, TSDB_TABLE_ID_LEN);
|
||||
tstrncpy(dataBuf->tableId, name, sizeof(dataBuf->tableId));
|
||||
|
||||
/*
|
||||
* The table meta may be released since the table meta cache are completed clean by other thread
|
||||
|
@ -1666,7 +1666,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
|
|||
assert(pTableMetaInfo != NULL);
|
||||
|
||||
if (name != NULL) {
|
||||
strncpy(pTableMetaInfo->name, name, TSDB_TABLE_ID_LEN);
|
||||
tstrncpy(pTableMetaInfo->name, name, sizeof(pTableMetaInfo->name));
|
||||
}
|
||||
|
||||
pTableMetaInfo->pTableMeta = pTableMeta;
|
||||
|
|
|
@ -73,8 +73,8 @@ void *cqOpen(void *ahandle, const SCqCfg *pCfg) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(pContext->user, pCfg->user);
|
||||
strcpy(pContext->pass, pCfg->pass);
|
||||
tstrncpy(pContext->user, pCfg->user, sizeof(pContext->user));
|
||||
tstrncpy(pContext->pass, pCfg->pass, sizeof(pContext->pass));
|
||||
const char* db = pCfg->db;
|
||||
for (const char* p = db; *p != 0; p++) {
|
||||
if (*p == '.') {
|
||||
|
@ -82,7 +82,7 @@ void *cqOpen(void *ahandle, const SCqCfg *pCfg) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
strcpy(pContext->db, db);
|
||||
tstrncpy(pContext->db, db, sizeof(pContext->db));
|
||||
pContext->vgId = pCfg->vgId;
|
||||
pContext->cqWrite = pCfg->cqWrite;
|
||||
pContext->ahandle = ahandle;
|
||||
|
@ -215,7 +215,7 @@ void cqDrop(void *handle) {
|
|||
cTrace("vgId:%d, id:%d CQ:%s is dropped", pContext->vgId, pObj->tid, pObj->sqlStr);
|
||||
free(pObj);
|
||||
|
||||
pthread_mutex_lock(&pContext->mutex);
|
||||
pthread_mutex_unlock(&pContext->mutex);
|
||||
}
|
||||
|
||||
static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct {
|
|||
int vgId;
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
FCqWrite cqWrite;
|
||||
} SCqCfg;
|
||||
|
||||
|
|
|
@ -756,7 +756,7 @@ void *readMetric(void *sarg) {
|
|||
|
||||
for (int j = 0; j < n; j++) {
|
||||
char condition[BUFFER_SIZE - 30] = "\0";
|
||||
char tempS[BUFFER_SIZE] = "\0";
|
||||
char tempS[64] = "\0";
|
||||
|
||||
int m = 10 < num_of_tables ? 10 : num_of_tables;
|
||||
|
||||
|
|
|
@ -643,6 +643,8 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
|
|||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
while (read(fd, &tableRecord, sizeof(STableRecord)) > 0) {
|
||||
tableRecord.name[sizeof(tableRecord.name) - 1] = 0;
|
||||
tableRecord.metric[sizeof(tableRecord.metric) - 1] = 0;
|
||||
taosDumpTable(tableRecord.name, tableRecord.metric, arguments, fp);
|
||||
}
|
||||
|
||||
|
@ -902,6 +904,8 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
|
|||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
while (read(fd, &tableRecord, sizeof(STableRecord)) > 0) {
|
||||
tableRecord.name[sizeof(tableRecord.name) - 1] = 0;
|
||||
tableRecord.metric[sizeof(tableRecord.metric) - 1] = 0;
|
||||
taosDumpTable(tableRecord.name, tableRecord.metric, arguments, fp);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ struct SMnodeObj;
|
|||
typedef struct SDnodeObj {
|
||||
int32_t dnodeId;
|
||||
uint16_t dnodePort;
|
||||
char dnodeFqdn[TSDB_FQDN_LEN + 1];
|
||||
char dnodeEp[TSDB_EP_LEN + 1];
|
||||
char dnodeFqdn[TSDB_FQDN_LEN];
|
||||
char dnodeEp[TSDB_EP_LEN];
|
||||
int64_t createdTime;
|
||||
uint32_t lastAccess;
|
||||
int32_t openVnodes;
|
||||
|
|
|
@ -1769,8 +1769,8 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
strncpy(pCreateMsg->tableId, pInfo->tableId, tListLen(pInfo->tableId));
|
||||
strcpy(pCreateMsg->db, pMsg->pDb->name);
|
||||
tstrncpy(pCreateMsg->tableId, pInfo->tableId, sizeof(pInfo->tableId));
|
||||
tstrncpy(pCreateMsg->db, pMsg->pDb->name, sizeof(pCreateMsg->db));
|
||||
pCreateMsg->igExists = 1;
|
||||
pCreateMsg->getMeta = 1;
|
||||
pCreateMsg->contLen = htonl(contLen);
|
||||
|
|
|
@ -160,7 +160,7 @@ static void taosGetSystemTimezone() {
|
|||
|
||||
/* load time zone string from /etc/timezone */
|
||||
FILE *f = fopen("/etc/timezone", "r");
|
||||
char buf[64] = {0};
|
||||
char buf[65] = {0};
|
||||
if (f != NULL) {
|
||||
fread(buf, 64, 1, f);
|
||||
fclose(f);
|
||||
|
|
|
@ -88,8 +88,8 @@ bool httpParseTaosdAuthToken(HttpContext *pContext, char *token, int len) {
|
|||
free(base64);
|
||||
return false;
|
||||
} else {
|
||||
strncpy(pContext->user, descrypt, TSDB_USER_LEN);
|
||||
strncpy(pContext->pass, descrypt + TSDB_USER_LEN, TSDB_PASSWORD_LEN);
|
||||
tstrncpy(pContext->user, descrypt, sizeof(pContext->user));
|
||||
tstrncpy(pContext->pass, descrypt + TSDB_USER_LEN, TSDB_PASSWORD_LEN);
|
||||
|
||||
httpTrace("context:%p, fd:%d, ip:%s, taosd token:%s parsed success, user:%s", pContext, pContext->fd,
|
||||
pContext->ipstr, token, pContext->user);
|
||||
|
|
|
@ -156,7 +156,7 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) {
|
|||
", io_read float, io_write float"
|
||||
", req_http int, req_select int, req_insert int"
|
||||
") tags (dnodeid int, fqdn binary(%d))",
|
||||
tsMonitorDbName, TSDB_FQDN_LEN + 1);
|
||||
tsMonitorDbName, TSDB_FQDN_LEN);
|
||||
} else if (cmd == MONITOR_CMD_CREATE_TB_DN) {
|
||||
snprintf(sql, SQL_LENGTH, "create table if not exists %s.dn%d using %s.dn tags(%d, '%s')", tsMonitorDbName,
|
||||
dnodeGetDnodeId(), tsMonitorDbName, dnodeGetDnodeId(), tsLocalEp);
|
||||
|
|
|
@ -5242,7 +5242,7 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
|
|||
if (pQuery->colList[i].numOfFilters > 0) {
|
||||
SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[j];
|
||||
|
||||
memcpy(&pFilterInfo->info, &pQuery->colList[i], sizeof(SColumnInfoData));
|
||||
memcpy(&pFilterInfo->info, &pQuery->colList[i], sizeof(SColumnInfo));
|
||||
pFilterInfo->info = pQuery->colList[i];
|
||||
|
||||
pFilterInfo->numOfFilters = pQuery->colList[i].numOfFilters;
|
||||
|
|
|
@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "-c") == 0 && i < argc - 1) {
|
||||
strncpy(configDir, argv[++i], MAX_FILE_NAME_LEN);
|
||||
tstrncpy(configDir, argv[++i], MAX_FILE_NAME_LEN);
|
||||
} else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) {
|
||||
strcpy(scriptFile, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-a") == 0) {
|
||||
|
|
Loading…
Reference in New Issue