From fbf249f28c6ec4a76cc7e728a5c75bd5ef3edd0f Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Tue, 9 Jun 2020 17:15:06 +0800 Subject: [PATCH] fix coverity 290758, 267837 --- src/client/src/tscServer.c | 4 ++-- src/inc/taosmsg.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index f01ec1bece..33ab93d113 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2150,7 +2150,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; SCMConnectRsp *pConnect = (SCMConnectRsp *)pRes->pRsp; - strcpy(pObj->acctId, pConnect->acctId); // copy acctId from response + tstrncpy(pObj->acctId, pConnect->acctId, sizeof(pObj->acctId)); // copy acctId from response int32_t len = sprintf(temp, "%s%s%s", pObj->acctId, TS_PATH_DELIMITER, pObj->db); assert(len <= sizeof(pObj->db)); @@ -2172,7 +2172,7 @@ int tscProcessUseDbRsp(SSqlObj *pSql) { STscObj * pObj = pSql->pTscObj; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); - strcpy(pObj->db, pTableMetaInfo->name); + tstrncpy(pObj->db, pTableMetaInfo->name, sizeof(pObj->db)); return 0; } diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index dca8287394..6a0219d6fc 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -296,7 +296,7 @@ typedef struct { } SCMConnectMsg; typedef struct { - char acctId[TSDB_ACCT_LEN + 1]; + char acctId[TSDB_ACCT_LEN]; char serverVersion[TSDB_VERSION_LEN]; int8_t writeAuth; int8_t superAuth; -- GitLab