From 3d0ce022f03b10c8998c1ec9722601682d49df60 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 3 Jan 2021 12:43:02 +0000 Subject: [PATCH] refactor code --- src/client/src/tscSql.c | 2 +- src/client/src/tscSystem.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 0730fffdd5..2390df5f21 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -91,7 +91,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa if (tscSetMgmtEpSetFromCfg(tsFirst, tsSecond, &corMgmtEpSet) < 0) return NULL; } char rpcKey[512] = {0}; - sprintf(rpcKey, "%s:%s:%s:%d", user, pass, ip, port); + snprintf(rpcKey, sizeof(rpcKey), "%s:%s:%s:%d", user, pass, ip, port); void *pRpcObj = NULL; if (tscAcquireRpc(rpcKey, user, secretEncrypt,&corMgmtEpSet, &pRpcObj) != 0) { diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 7a92b4fc05..66fe4100b2 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -109,6 +109,7 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry if (pRpcObj->tscCorMgmtEpSet == NULL) { rpcClose(rpcObj.pDnodeConn); pthread_mutex_unlock(&rpcObjMutex); + return -1; } memcpy(pRpcObj->tscCorMgmtEpSet, corMgmtEpSet, sizeof(*corMgmtEpSet)); -- GitLab