Merge pull request #2355 from taosdata/hotfix/crash
[TD-543] fix coverity scans
This commit is contained in:
commit
0101bc6ebe
|
@ -52,7 +52,7 @@ bool gcGetUserFromUrl(HttpContext* pContext) {
|
|||
return false;
|
||||
}
|
||||
|
||||
strcpy(pContext->user, pParser->path[GC_USER_URL_POS].pos);
|
||||
tstrncpy(pContext->user, pParser->path[GC_USER_URL_POS].pos, TSDB_USER_LEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ bool gcGetPassFromUrl(HttpContext* pContext) {
|
|||
return false;
|
||||
}
|
||||
|
||||
strcpy(pContext->pass, pParser->path[GC_PASS_URL_POS].pos);
|
||||
tstrncpy(pContext->pass, pParser->path[GC_PASS_URL_POS].pos, TSDB_PASSWORD_LEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ bool httpParseBasicAuthToken(HttpContext *pContext, char *token, int len) {
|
|||
char *base64 = (char *)base64_decode(token, len, &outlen);
|
||||
if (base64 == NULL || outlen == 0) {
|
||||
httpError("context:%p, fd:%d, ip:%s, basic token:%s parsed error", pContext, pContext->fd, pContext->ipstr, token);
|
||||
free(base64);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -442,13 +442,12 @@ void httpJsonPairStatus(JsonBuf* buf, int code) {
|
|||
httpJsonPair(buf, "status", 6, "error", 5);
|
||||
httpJsonItemToken(buf);
|
||||
httpJsonPairIntVal(buf, "code", 4, code);
|
||||
if (code >= 0) {
|
||||
httpJsonItemToken(buf);
|
||||
if (code == TSDB_CODE_MND_DB_NOT_SELECTED) {
|
||||
httpJsonPair(buf, "desc", 4, "failed to create database", 23);
|
||||
} else if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) {
|
||||
httpJsonPair(buf, "desc", 4, "failed to create table", 22);
|
||||
} else
|
||||
} else {
|
||||
httpJsonPair(buf, "desc", 4, (char*)tstrerror(code), (int)strlen(tstrerror(code)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,8 +202,7 @@ bool httpReMallocMultiCmdsSize(HttpContext *pContext, int cmdSize) {
|
|||
pContext->user, cmdSize);
|
||||
return false;
|
||||
}
|
||||
memset(multiCmds->cmds + multiCmds->maxSize * (int16_t)sizeof(HttpSqlCmd), 0,
|
||||
(size_t)(cmdSize - multiCmds->maxSize) * sizeof(HttpSqlCmd));
|
||||
memset(multiCmds->cmds + multiCmds->maxSize, 0, (size_t)(cmdSize - multiCmds->maxSize) * sizeof(HttpSqlCmd));
|
||||
multiCmds->maxSize = (int16_t)cmdSize;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -65,7 +65,7 @@ bool restGetUserFromUrl(HttpContext* pContext) {
|
|||
return false;
|
||||
}
|
||||
|
||||
strcpy(pContext->user, pParser->path[REST_USER_URL_POS].pos);
|
||||
tstrncpy(pContext->user, pParser->path[REST_USER_URL_POS].pos, TSDB_USER_LEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ bool restGetPassFromUrl(HttpContext* pContext) {
|
|||
return false;
|
||||
}
|
||||
|
||||
strcpy(pContext->pass, pParser->path[REST_PASS_URL_POS].pos);
|
||||
tstrncpy(pContext->pass, pParser->path[REST_PASS_URL_POS].pos, TSDB_PASSWORD_LEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -268,10 +268,10 @@ int tgReadSchema(char *fileName) {
|
|||
|
||||
httpPrint("open telegraf schema file:%s success", fileName);
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size_t contentSize = (size_t)ftell(fp);
|
||||
int32_t contentSize = (int32_t)ftell(fp);
|
||||
rewind(fp);
|
||||
char *content = (char *)calloc(contentSize * sizeof(char) + 1, 1);
|
||||
size_t result = fread(content, 1, contentSize, fp);
|
||||
char * content = (char *)calloc(contentSize + 1, 1);
|
||||
int32_t result = fread(content, 1, contentSize, fp);
|
||||
if (result != contentSize) {
|
||||
httpError("failed to read telegraf schema file:%s", fileName);
|
||||
fclose(fp);
|
||||
|
@ -279,6 +279,7 @@ int tgReadSchema(char *fileName) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
content[contentSize] = 0;
|
||||
int schemaNum = tgParseSchema(content, fileName);
|
||||
|
||||
free(content);
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef struct {
|
|||
char ep[TSDB_EP_LEN];
|
||||
int8_t cmdIndex;
|
||||
int8_t state;
|
||||
char sql[SQL_LENGTH];
|
||||
char sql[SQL_LENGTH + 1];
|
||||
void * initTimer;
|
||||
void * diskTimer;
|
||||
} SMonitorConn;
|
||||
|
|
|
@ -164,7 +164,7 @@ void mqtt_PublishCallback(void** unused, struct mqtt_response_publish* published
|
|||
void* mqttClientRefresher(void* client) {
|
||||
while (mttIsRuning) {
|
||||
mqtt_sync((struct mqtt_client*)client);
|
||||
usleep(100000U);
|
||||
taosMsleep(100);
|
||||
}
|
||||
mqttPrint("Exit mqttClientRefresher");
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue