diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 8dc2d4c993e001c95f63d72c60db8b8fe3ac3df8..7d1076abbf1eb0c35385b769bfc6a88cfd8a21a7 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((char*)reqMsg.pCont, "nettest", pktLen); rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); @@ -606,7 +606,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); @@ -614,8 +614,8 @@ 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((char*)reqMsg.pCont, "nettest speed", pkgLen); + rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); int code = 0;