From f4fad0c0ee71feba574fecf2e28bad1d55adf5e4 Mon Sep 17 00:00:00 2001 From: tiantian001 <1179804865@qq.com> Date: Sun, 12 Dec 2021 21:03:34 +0800 Subject: [PATCH] fix: change strcpy to tstrncpy --- src/util/src/tnettest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 2a147ee4f1..d5db42c04c 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -356,7 +356,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p epSet.inUse = 0; epSet.numOfEps = 1; epSet.port[0] = port; - strcpy(epSet.fqdn[0], serverFqdn); + tstrncpy(epSet.fqdn[0], serverFqdn, sizeof(epSet.fqdn[0])); reqMsg.msgType = TSDB_MSG_TYPE_NETWORK_TEST; reqMsg.pCont = rpcMallocCont(pktLen); @@ -364,7 +364,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p reqMsg.code = 0; reqMsg.handle = NULL; // rpc handle returned to app reqMsg.ahandle = NULL; // app handle set by client - strcpy(reqMsg.pCont, "nettest"); + tstrncpy(reqMsg.pCont, "nettest", sizeof(reqMsg.pCont)); rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); @@ -600,7 +600,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen, epSet.inUse = 0; epSet.numOfEps = 1; epSet.port[0] = port; - strcpy(epSet.fqdn[0], host); + tstrncpy(epSet.fqdn[0], host, sizeof(epSet.fqdn[0])); reqMsg.msgType = TSDB_MSG_TYPE_NETWORK_TEST; reqMsg.pCont = rpcMallocCont(pkgLen); @@ -608,7 +608,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen, reqMsg.code = 0; reqMsg.handle = NULL; // rpc handle returned to app reqMsg.ahandle = NULL; // app handle set by client - strcpy(reqMsg.pCont, "nettest speed"); + tstrncpy(reqMsg.pCont, "nettest speed", sizeof(reqMsg.pCont)); rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); -- GitLab