fix: snprintf
This commit is contained in:
parent
402f9daa2a
commit
e81e999fc1
|
@ -143,7 +143,7 @@ int32_t epsetToStr(const SEpSet* pEpSet, char* pBuf, int32_t cap) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
int32_t nwrite = 0;
|
int32_t nwrite = 0;
|
||||||
|
|
||||||
nwrite = tsnprintf(pBuf + nwrite, cap, "epset:{");
|
nwrite = snprintf(pBuf + nwrite, cap, "epset:{");
|
||||||
if (nwrite <= 0 || nwrite >= cap) {
|
if (nwrite <= 0 || nwrite >= cap) {
|
||||||
return TSDB_CODE_OUT_OF_BUFFER;
|
return TSDB_CODE_OUT_OF_BUFFER;
|
||||||
}
|
}
|
||||||
|
@ -151,9 +151,9 @@ int32_t epsetToStr(const SEpSet* pEpSet, char* pBuf, int32_t cap) {
|
||||||
|
|
||||||
for (int _i = 0; (_i < pEpSet->numOfEps) && (cap > 0); _i++) {
|
for (int _i = 0; (_i < pEpSet->numOfEps) && (cap > 0); _i++) {
|
||||||
if (_i == pEpSet->numOfEps - 1) {
|
if (_i == pEpSet->numOfEps - 1) {
|
||||||
ret = tsnprintf(pBuf + nwrite, cap, "%d. %s:%d", _i, pEpSet->eps[_i].fqdn, pEpSet->eps[_i].port);
|
ret = snprintf(pBuf + nwrite, cap, "%d. %s:%d", _i, pEpSet->eps[_i].fqdn, pEpSet->eps[_i].port);
|
||||||
} else {
|
} else {
|
||||||
ret = tsnprintf(pBuf + nwrite, cap, "%d. %s:%d, ", _i, pEpSet->eps[_i].fqdn, pEpSet->eps[_i].port);
|
ret = snprintf(pBuf + nwrite, cap, "%d. %s:%d, ", _i, pEpSet->eps[_i].fqdn, pEpSet->eps[_i].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret <= 0 || ret >= cap) {
|
if (ret <= 0 || ret >= cap) {
|
||||||
|
@ -168,7 +168,7 @@ int32_t epsetToStr(const SEpSet* pEpSet, char* pBuf, int32_t cap) {
|
||||||
return TSDB_CODE_OUT_OF_BUFFER;
|
return TSDB_CODE_OUT_OF_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = tsnprintf(pBuf + nwrite, cap, "}, inUse:%d", pEpSet->inUse);
|
ret = snprintf(pBuf + nwrite, cap, "}, inUse:%d", pEpSet->inUse);
|
||||||
if (ret <= 0 || ret >= cap) {
|
if (ret <= 0 || ret >= cap) {
|
||||||
return TSDB_CODE_OUT_OF_BUFFER;
|
return TSDB_CODE_OUT_OF_BUFFER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,7 +215,7 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
|
||||||
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores), NULL, _exit);
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores), NULL, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB);
|
int32_t nBytes = snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB);
|
||||||
if (nBytes <= 9 || nBytes >= sizeof(tmp)) {
|
if (nBytes <= 9 || nBytes >= sizeof(tmp)) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_RANGE, NULL, _exit);
|
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_RANGE, NULL, _exit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,7 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
||||||
char args[1024] = {0};
|
char args[1024] = {0};
|
||||||
int32_t arglen = tsnprintf(args, sizeof(args), "%s", argv[0]);
|
int32_t arglen = tsnprintf(args, sizeof(args), "%s", argv[0]);
|
||||||
for (int32_t i = 1; i < argc; ++i) {
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
arglen = arglen + snprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
arglen = arglen + tsnprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("startup path:%s args:%s", path, args);
|
dInfo("startup path:%s args:%s", path, args);
|
||||||
|
|
|
@ -64,7 +64,7 @@ int32_t mmReadFile(const char *path, SMnodeOpt *pOption) {
|
||||||
SJson *pJson = NULL;
|
SJson *pJson = NULL;
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(file, sizeof(file), "%s%smnode.json", path, TD_DIRSEP);
|
int32_t nBytes = snprintf(file, sizeof(file), "%s%smnode.json", path, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -168,13 +168,13 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(file, sizeof(file), "%s%smnode.json.bak", path, TD_DIRSEP);
|
int32_t nBytes = snprintf(file, sizeof(file), "%s%smnode.json.bak", path, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(realfile, sizeof(realfile), "%s%smnode.json", path, TD_DIRSEP);
|
nBytes = snprintf(realfile, sizeof(realfile), "%s%smnode.json", path, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(realfile)) {
|
if (nBytes <= 0 || nBytes >= sizeof(realfile)) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -204,12 +204,12 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(file, sizeof(file), "%s%svnodes_tmp.json", pMgmt->path, TD_DIRSEP);
|
int32_t nBytes = snprintf(file, sizeof(file), "%s%svnodes_tmp.json", pMgmt->path, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(realfile, sizeof(realfile), "%s%svnodes.json", pMgmt->path, TD_DIRSEP);
|
nBytes = snprintf(realfile, sizeof(realfile), "%s%svnodes.json", pMgmt->path, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(realfile)) {
|
if (nBytes <= 0 || nBytes >= sizeof(realfile)) {
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed) {
|
||||||
char *content = NULL;
|
char *content = NULL;
|
||||||
SJson *pJson = NULL;
|
SJson *pJson = NULL;
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
int32_t nBytes = tsnprintf(file, sizeof(file), "%s%s%s.json", path, TD_DIRSEP, name);
|
int32_t nBytes = snprintf(file, sizeof(file), "%s%s%s.json", path, TD_DIRSEP, name);
|
||||||
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -120,13 +120,13 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) {
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(file, sizeof(file), "%s%s%s.json", path, TD_DIRSEP, name);
|
int32_t nBytes = snprintf(file, sizeof(file), "%s%s%s.json", path, TD_DIRSEP, name);
|
||||||
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(realfile, sizeof(realfile), "%s%s%s.json", path, TD_DIRSEP, name);
|
nBytes = snprintf(realfile, sizeof(realfile), "%s%s%s.json", path, TD_DIRSEP, name);
|
||||||
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -387,22 +387,22 @@ int32_t dmUpdateEncryptKey(char *key, bool toLogFile) {
|
||||||
char checkFile[PATH_MAX] = {0};
|
char checkFile[PATH_MAX] = {0};
|
||||||
char realCheckFile[PATH_MAX] = {0};
|
char realCheckFile[PATH_MAX] = {0};
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(folder, sizeof(folder), "%s%sdnode", tsDataDir, TD_DIRSEP);
|
int32_t nBytes = snprintf(folder, sizeof(folder), "%s%sdnode", tsDataDir, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
||||||
return TSDB_CODE_OUT_OF_BUFFER;
|
return TSDB_CODE_OUT_OF_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(encryptFile, sizeof(realEncryptFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
nBytes = snprintf(encryptFile, sizeof(realEncryptFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||||
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
||||||
return TSDB_CODE_OUT_OF_BUFFER;
|
return TSDB_CODE_OUT_OF_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(realEncryptFile, sizeof(realEncryptFile), "%s%s%s", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
nBytes = snprintf(realEncryptFile, sizeof(realEncryptFile), "%s%s%s", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||||
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
||||||
return TSDB_CODE_OUT_OF_BUFFER;
|
return TSDB_CODE_OUT_OF_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(checkFile, sizeof(checkFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
nBytes = snprintf(checkFile, sizeof(checkFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||||
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
if (nBytes <= 0 || nBytes >= PATH_MAX) {
|
||||||
return TSDB_CODE_OUT_OF_BUFFER;
|
return TSDB_CODE_OUT_OF_BUFFER;
|
||||||
}
|
}
|
||||||
|
@ -507,14 +507,14 @@ int32_t dmGetEncryptKey() {
|
||||||
char *encryptKey = NULL;
|
char *encryptKey = NULL;
|
||||||
char *content = NULL;
|
char *content = NULL;
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(encryptFile, sizeof(encryptFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP,
|
int32_t nBytes = snprintf(encryptFile, sizeof(encryptFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP,
|
||||||
DM_ENCRYPT_CODE_FILE);
|
DM_ENCRYPT_CODE_FILE);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(encryptFile)) {
|
if (nBytes <= 0 || nBytes >= sizeof(encryptFile)) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(checkFile, sizeof(checkFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
nBytes = snprintf(checkFile, sizeof(checkFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(checkFile)) {
|
if (nBytes <= 0 || nBytes >= sizeof(checkFile)) {
|
||||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -835,7 +835,7 @@ static int32_t mndProcessAnalAlgoReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
for (int32_t a = 0; a < taosArrayGetSize(algos); ++a) {
|
for (int32_t a = 0; a < taosArrayGetSize(algos); ++a) {
|
||||||
SAnodeAlgo *algo = taosArrayGet(algos, a);
|
SAnodeAlgo *algo = taosArrayGet(algos, a);
|
||||||
nameLen = 1 + snprintf(name, sizeof(name) - 1, "%d:%s", url.type, algo->name);
|
nameLen = 1 + tsnprintf(name, sizeof(name) - 1, "%d:%s", url.type, algo->name);
|
||||||
|
|
||||||
SAnalUrl *pOldUrl = taosHashAcquire(rsp.hash, name, nameLen);
|
SAnalUrl *pOldUrl = taosHashAcquire(rsp.hash, name, nameLen);
|
||||||
if (pOldUrl == NULL || (pOldUrl != NULL && pOldUrl->anode < url.anode)) {
|
if (pOldUrl == NULL || (pOldUrl != NULL && pOldUrl->anode < url.anode)) {
|
||||||
|
@ -852,7 +852,7 @@ static int32_t mndProcessAnalAlgoReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
url.urlLen = 1 + snprintf(url.url, TSDB_ANAL_ANODE_URL_LEN + TSDB_ANAL_ALGO_TYPE_LEN, "%s/%s", pAnode->url,
|
url.urlLen = 1 + tsnprintf(url.url, TSDB_ANAL_ANODE_URL_LEN + TSDB_ANAL_ALGO_TYPE_LEN, "%s/%s", pAnode->url,
|
||||||
taosAnalAlgoUrlStr(url.type));
|
taosAnalAlgoUrlStr(url.type));
|
||||||
if (taosHashPut(rsp.hash, name, nameLen, &url, sizeof(SAnalUrl)) != 0) {
|
if (taosHashPut(rsp.hash, name, nameLen, &url, sizeof(SAnalUrl)) != 0) {
|
||||||
taosMemoryFree(url.url);
|
taosMemoryFree(url.url);
|
||||||
|
|
|
@ -2252,7 +2252,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
||||||
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||||
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
||||||
len += tsnprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
len += snprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
||||||
((SExprNode *)pFunc)->userAlias);
|
((SExprNode *)pFunc)->userAlias);
|
||||||
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
||||||
len = TSDB_MAX_SAVED_SQL_LEN;
|
len = TSDB_MAX_SAVED_SQL_LEN;
|
||||||
|
|
|
@ -216,7 +216,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(state, cap, "%s%s%s", path, TD_DIRSEP, "state");
|
nBytes = snprintf(state, cap, "%s%s%s", path, TD_DIRSEP, "state");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(state);
|
taosMemoryFree(state);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
@ -229,7 +229,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(chkp, cap, "%s%s%s%scheckpoint%" PRId64 "", path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId);
|
nBytes = snprintf(chkp, cap, "%s%s%s%scheckpoint%" PRId64 "", path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(state);
|
taosMemoryFree(state);
|
||||||
taosMemoryFree(chkp);
|
taosMemoryFree(chkp);
|
||||||
|
@ -282,7 +282,7 @@ int32_t remoteChkp_readMetaData(char* path, SSChkpMetaOnS3** pMeta) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t n = tsnprintf(metaPath, cap, "%s%s%s", path, TD_DIRSEP, "META");
|
int32_t n = snprintf(metaPath, cap, "%s%s%s", path, TD_DIRSEP, "META");
|
||||||
if (n <= 0 || n >= cap) {
|
if (n <= 0 || n >= cap) {
|
||||||
taosMemoryFree(metaPath);
|
taosMemoryFree(metaPath);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -350,7 +350,7 @@ int32_t remoteChkp_validAndCvtMeta(char* path, SSChkpMetaOnS3* pMeta, int64_t ch
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(src, cap, "%s%s%s_%" PRId64 "", path, TD_DIRSEP, key, pMeta->currChkptId);
|
nBytes = snprintf(src, cap, "%s%s%s_%" PRId64 "", path, TD_DIRSEP, key, pMeta->currChkptId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
|
@ -361,7 +361,7 @@ int32_t remoteChkp_validAndCvtMeta(char* path, SSChkpMetaOnS3* pMeta, int64_t ch
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(dst, cap, "%s%s%s", path, TD_DIRSEP, key);
|
nBytes = snprintf(dst, cap, "%s%s%s", path, TD_DIRSEP, key);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
|
@ -403,7 +403,7 @@ int32_t remoteChkpGetDelFile(char* path, SArray* toDel) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(p, cap, "%s_%" PRId64 "", key, pMeta->currChkptId);
|
nBytes = snprintf(p, cap, "%s_%" PRId64 "", key, pMeta->currChkptId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(pMeta);
|
taosMemoryFree(pMeta);
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
|
@ -499,7 +499,7 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(defaultPath, cap, "%s%s", defaultPath, "_tmp");
|
int32_t nBytes = snprintf(defaultPath, cap, "%s%s", defaultPath, "_tmp");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(defaultPath);
|
taosMemoryFree(defaultPath);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
@ -611,13 +611,13 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(srcName, cap, "%s%s%s", src, TD_DIRSEP, name);
|
nBytes = snprintf(srcName, cap, "%s%s%s", src, TD_DIRSEP, name);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(dstName, cap, "%s%s%s", dst, TD_DIRSEP, name);
|
nBytes = snprintf(dstName, cap, "%s%s%s", dst, TD_DIRSEP, name);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
|
@ -715,7 +715,7 @@ int32_t restoreCheckpointData(const char* path, const char* key, int64_t chkptId
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(prefixPath, cap, "%s%s%s", path, TD_DIRSEP, key);
|
nBytes = snprintf(prefixPath, cap, "%s%s%s", path, TD_DIRSEP, key);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
|
@ -727,7 +727,7 @@ int32_t restoreCheckpointData(const char* path, const char* key, int64_t chkptId
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(defaultPath, cap, "%s%s%s", prefixPath, TD_DIRSEP, "state");
|
nBytes = snprintf(defaultPath, cap, "%s%s%s", prefixPath, TD_DIRSEP, "state");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
|
@ -739,7 +739,7 @@ int32_t restoreCheckpointData(const char* path, const char* key, int64_t chkptId
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(checkpointRoot, cap, "%s%s%s", prefixPath, TD_DIRSEP, "checkpoints");
|
nBytes = snprintf(checkpointRoot, cap, "%s%s%s", prefixPath, TD_DIRSEP, "checkpoints");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
|
@ -753,7 +753,7 @@ int32_t restoreCheckpointData(const char* path, const char* key, int64_t chkptId
|
||||||
|
|
||||||
stDebug("%s check local backend dir:%s, checkpointId:%" PRId64 " succ", key, defaultPath, chkptId);
|
stDebug("%s check local backend dir:%s, checkpointId:%" PRId64 " succ", key, defaultPath, chkptId);
|
||||||
if (chkptId > 0) {
|
if (chkptId > 0) {
|
||||||
nBytes = tsnprintf(checkpointPath, cap, "%s%s%s%s%s%" PRId64 "", prefixPath, TD_DIRSEP, "checkpoints", TD_DIRSEP,
|
nBytes = snprintf(checkpointPath, cap, "%s%s%s%s%s%" PRId64 "", prefixPath, TD_DIRSEP, "checkpoints", TD_DIRSEP,
|
||||||
"checkpoint", chkptId);
|
"checkpoint", chkptId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
@ -800,7 +800,7 @@ bool streamBackendDataIsExist(const char* path, int64_t chkpId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t nBytes = tsnprintf(state, cap, "%s%s%s", path, TD_DIRSEP, "state");
|
int16_t nBytes = snprintf(state, cap, "%s%s%s", path, TD_DIRSEP, "state");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
terrno = TSDB_CODE_OUT_OF_RANGE;
|
||||||
exist = false;
|
exist = false;
|
||||||
|
@ -1322,13 +1322,13 @@ int32_t chkpPreBuildDir(char* path, int64_t chkpId, char** chkpDir, char** chkpI
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(pChkpDir, cap, "%s%s%s", path, TD_DIRSEP, "checkpoints");
|
nBytes = snprintf(pChkpDir, cap, "%s%s%s", path, TD_DIRSEP, "checkpoints");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(pChkpIdDir, cap, "%s%s%s%" PRId64, pChkpDir, TD_DIRSEP, "checkpoint", chkpId);
|
nBytes = snprintf(pChkpIdDir, cap, "%s%s%s%" PRId64, pChkpDir, TD_DIRSEP, "checkpoint", chkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
|
@ -1500,7 +1500,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId)
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(pDst, cap, "%s%sinfo", pChkpIdDir, TD_DIRSEP);
|
nBytes = snprintf(pDst, cap, "%s%sinfo", pChkpIdDir, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
stError("failed to build dst to load extra info, dir:%s", pChkpIdDir);
|
stError("failed to build dst to load extra info, dir:%s", pChkpIdDir);
|
||||||
|
@ -1556,7 +1556,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(pDst, cap, "%s%sinfo", pChkpIdDir, TD_DIRSEP);
|
nBytes = snprintf(pDst, cap, "%s%sinfo", pChkpIdDir, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
stError("failed to build dst to add extra info, dir:%s, reason:%s", pChkpIdDir, tstrerror(code));
|
stError("failed to build dst to add extra info, dir:%s, reason:%s", pChkpIdDir, tstrerror(code));
|
||||||
|
@ -1570,7 +1570,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(buf, sizeof(buf), "%" PRId64 " %" PRId64 "", chkpId, processId);
|
nBytes = snprintf(buf, sizeof(buf), "%" PRId64 " %" PRId64 "", chkpId, processId);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(buf)) {
|
if (nBytes <= 0 || nBytes >= sizeof(buf)) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
stError("failed to build content to add extra info, dir:%s,reason:%s", pChkpIdDir, tstrerror(code));
|
stError("failed to build content to add extra info, dir:%s,reason:%s", pChkpIdDir, tstrerror(code));
|
||||||
|
@ -2727,7 +2727,7 @@ int32_t taskDbGenChkpUploadData__s3(STaskDbWrapper* pDb, void* bkdChkpMgt, int64
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(temp, cap, "%s%s%s%" PRId64, pDb->path, TD_DIRSEP, "tmp", chkpId);
|
int32_t nBytes = snprintf(temp, cap, "%s%s%s%" PRId64, pDb->path, TD_DIRSEP, "tmp", chkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(temp);
|
taosMemoryFree(temp);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
@ -4805,14 +4805,14 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
char* srcDir = &dstBuf[cap];
|
char* srcDir = &dstBuf[cap];
|
||||||
char* dstDir = &srcDir[cap];
|
char* dstDir = &srcDir[cap];
|
||||||
|
|
||||||
int nBytes = tsnprintf(srcDir, cap, "%s%s%s%s%s%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP,
|
int nBytes = snprintf(srcDir, cap, "%s%s%s%s%s%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP,
|
||||||
"checkpoint", p->curChkpId);
|
"checkpoint", p->curChkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(dstDir, cap, "%s", dname);
|
nBytes = snprintf(dstDir, cap, "%s", dname);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
|
@ -4837,13 +4837,13 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
memset(dstBuf, 0, cap);
|
memset(dstBuf, 0, cap);
|
||||||
|
|
||||||
char* filename = taosArrayGetP(p->pAdd, i);
|
char* filename = taosArrayGetP(p->pAdd, i);
|
||||||
nBytes = tsnprintf(srcBuf, cap, "%s%s%s", srcDir, TD_DIRSEP, filename);
|
nBytes = snprintf(srcBuf, cap, "%s%s%s", srcDir, TD_DIRSEP, filename);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(dstBuf, cap, "%s%s%s", dstDir, TD_DIRSEP, filename);
|
nBytes = snprintf(dstBuf, cap, "%s%s%s", dstDir, TD_DIRSEP, filename);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
|
@ -4874,13 +4874,13 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
memset(srcBuf, 0, cap);
|
memset(srcBuf, 0, cap);
|
||||||
memset(dstBuf, 0, cap);
|
memset(dstBuf, 0, cap);
|
||||||
|
|
||||||
nBytes = tsnprintf(srcBuf, cap, "%s%s%s", srcDir, TD_DIRSEP, p->pCurrent);
|
nBytes = snprintf(srcBuf, cap, "%s%s%s", srcDir, TD_DIRSEP, p->pCurrent);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(dstBuf, cap, "%s%s%s_%" PRId64 "", dstDir, TD_DIRSEP, p->pCurrent, p->curChkpId);
|
nBytes = snprintf(dstBuf, cap, "%s%s%s_%" PRId64 "", dstDir, TD_DIRSEP, p->pCurrent, p->curChkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
|
@ -4896,13 +4896,13 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
memset(srcBuf, 0, cap);
|
memset(srcBuf, 0, cap);
|
||||||
memset(dstBuf, 0, cap);
|
memset(dstBuf, 0, cap);
|
||||||
|
|
||||||
nBytes = tsnprintf(srcBuf, cap, "%s%s%s", srcDir, TD_DIRSEP, p->pManifest);
|
nBytes = snprintf(srcBuf, cap, "%s%s%s", srcDir, TD_DIRSEP, p->pManifest);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(dstBuf, cap, "%s%s%s_%" PRId64 "", dstDir, TD_DIRSEP, p->pManifest, p->curChkpId);
|
nBytes = snprintf(dstBuf, cap, "%s%s%s_%" PRId64 "", dstDir, TD_DIRSEP, p->pManifest, p->curChkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
|
@ -4914,7 +4914,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
memset(dstBuf, 0, cap);
|
memset(dstBuf, 0, cap);
|
||||||
nBytes = tsnprintf(dstDir, cap, "%s%s%s", dstDir, TD_DIRSEP, chkpMeta);
|
nBytes = snprintf(dstDir, cap, "%s%s%s", dstDir, TD_DIRSEP, chkpMeta);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
|
@ -5018,7 +5018,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId);
|
int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(path);
|
taosMemoryFree(path);
|
||||||
TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
|
TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
|
||||||
|
|
|
@ -710,7 +710,7 @@ static int32_t getCheckpointDataMeta(const char* id, const char* path, SArray* l
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(filePath, cap, "%s%s%s", path, TD_DIRSEP, "META_TMP");
|
int32_t nBytes = snprintf(filePath, cap, "%s%s%s", path, TD_DIRSEP, "META_TMP");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(filePath);
|
taosMemoryFree(filePath);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
@ -1304,13 +1304,13 @@ static int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
||||||
|
|
||||||
char filename[PATH_MAX] = {0};
|
char filename[PATH_MAX] = {0};
|
||||||
if (path[strlen(path) - 1] == TD_DIRSEP_CHAR) {
|
if (path[strlen(path) - 1] == TD_DIRSEP_CHAR) {
|
||||||
nBytes = tsnprintf(filename, sizeof(filename), "%s%s", path, name);
|
nBytes = snprintf(filename, sizeof(filename), "%s%s", path, name);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(filename)) {
|
if (nBytes <= 0 || nBytes >= sizeof(filename)) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nBytes = tsnprintf(filename, sizeof(filename), "%s%s%s", path, TD_DIRSEP, name);
|
nBytes = snprintf(filename, sizeof(filename), "%s%s%s", path, TD_DIRSEP, name);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(filename)) {
|
if (nBytes <= 0 || nBytes >= sizeof(filename)) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
break;
|
break;
|
||||||
|
@ -1318,7 +1318,7 @@ static int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char object[PATH_MAX] = {0};
|
char object[PATH_MAX] = {0};
|
||||||
nBytes = tsnprintf(object, sizeof(object), "%s%s%s", id, TD_DIRSEP, name);
|
nBytes = snprintf(object, sizeof(object), "%s%s%s", id, TD_DIRSEP, name);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(object)) {
|
if (nBytes <= 0 || nBytes >= sizeof(object)) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
break;
|
break;
|
||||||
|
@ -1349,7 +1349,7 @@ int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(buf, cap, "%s/%s", id, fname);
|
nBytes = snprintf(buf, cap, "%s/%s", id, fname);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
@ -1439,7 +1439,7 @@ int32_t deleteCheckpoint(const char* id) {
|
||||||
int32_t deleteCheckpointFile(const char* id, const char* name) {
|
int32_t deleteCheckpointFile(const char* id, const char* name) {
|
||||||
char object[128] = {0};
|
char object[128] = {0};
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(object, sizeof(object), "%s/%s", id, name);
|
int32_t nBytes = snprintf(object, sizeof(object), "%s/%s", id, name);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(object)) {
|
if (nBytes <= 0 || nBytes >= sizeof(object)) {
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ void snapFileDebugInfo(SBackendSnapFile2* pSnapFile) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nBytes = tsnprintf(buf + strlen(buf), cap, "[");
|
int32_t nBytes = snprintf(buf + strlen(buf), cap, "[");
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
stError("%s failed to write buf, reason:%s", STREAM_STATE_TRANSFER, tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
stError("%s failed to write buf, reason:%s", STREAM_STATE_TRANSFER, tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
||||||
|
@ -355,7 +355,7 @@ int32_t streamBackendSnapInitFile(char* metaPath, SStreamTaskSnap* pSnap, SBacke
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
nBytes = tsnprintf(path, cap, "%s%s%s%s%s%" PRId64 "", pSnap->dbPrefixPath, TD_DIRSEP, "checkpoints", TD_DIRSEP,
|
nBytes = snprintf(path, cap, "%s%s%s%s%s%" PRId64 "", pSnap->dbPrefixPath, TD_DIRSEP, "checkpoints", TD_DIRSEP,
|
||||||
"checkpoint", pSnap->chkpId);
|
"checkpoint", pSnap->chkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
|
|
@ -102,14 +102,14 @@ static int32_t taosBuildHttpHeader(const char* server, const char* uri, int32_t
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
if (flag == HTTP_FLAT) {
|
if (flag == HTTP_FLAT) {
|
||||||
if (qid == NULL) {
|
if (qid == NULL) {
|
||||||
len = tsnprintf(pHead, headLen,
|
len = snprintf(pHead, headLen,
|
||||||
"POST %s HTTP/1.1\n"
|
"POST %s HTTP/1.1\n"
|
||||||
"Host: %s\n"
|
"Host: %s\n"
|
||||||
"Content-Type: application/json\n"
|
"Content-Type: application/json\n"
|
||||||
"Content-Length: %d\n\n",
|
"Content-Length: %d\n\n",
|
||||||
uri, server, contLen);
|
uri, server, contLen);
|
||||||
} else {
|
} else {
|
||||||
len = tsnprintf(pHead, headLen,
|
len = snprintf(pHead, headLen,
|
||||||
"POST %s HTTP/1.1\n"
|
"POST %s HTTP/1.1\n"
|
||||||
"Host: %s\n"
|
"Host: %s\n"
|
||||||
"X-QID: %s\n"
|
"X-QID: %s\n"
|
||||||
|
@ -122,7 +122,7 @@ static int32_t taosBuildHttpHeader(const char* server, const char* uri, int32_t
|
||||||
}
|
}
|
||||||
} else if (flag == HTTP_GZIP) {
|
} else if (flag == HTTP_GZIP) {
|
||||||
if (qid == NULL) {
|
if (qid == NULL) {
|
||||||
len = tsnprintf(pHead, headLen,
|
len = snprintf(pHead, headLen,
|
||||||
"POST %s HTTP/1.1\n"
|
"POST %s HTTP/1.1\n"
|
||||||
"Host: %s\n"
|
"Host: %s\n"
|
||||||
"Content-Type: application/json\n"
|
"Content-Type: application/json\n"
|
||||||
|
@ -130,7 +130,7 @@ static int32_t taosBuildHttpHeader(const char* server, const char* uri, int32_t
|
||||||
"Content-Length: %d\n\n",
|
"Content-Length: %d\n\n",
|
||||||
uri, server, contLen);
|
uri, server, contLen);
|
||||||
} else {
|
} else {
|
||||||
len = tsnprintf(pHead, headLen,
|
len = snprintf(pHead, headLen,
|
||||||
"POST %s HTTP/1.1\n"
|
"POST %s HTTP/1.1\n"
|
||||||
"Host: %s\n"
|
"Host: %s\n"
|
||||||
"X-QID: %s\n"
|
"X-QID: %s\n"
|
||||||
|
|
|
@ -1042,9 +1042,12 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
|
||||||
if (h != S_OK) {
|
if (h != S_OK) {
|
||||||
return TAOS_SYSTEM_WINAPI_ERROR(GetLastError());
|
return TAOS_SYSTEM_WINAPI_ERROR(GetLastError());
|
||||||
}
|
}
|
||||||
snprintf(uid, uidlen, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3,
|
int n = snprintf(uid, uidlen, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3,
|
||||||
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6],
|
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6],
|
||||||
guid.Data4[7]);
|
guid.Data4[7]);
|
||||||
|
if(n >= uidlen) {
|
||||||
|
return TSDB_CODE_OUT_OF_BUFFER;;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
@ -1054,7 +1057,10 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
|
||||||
uuid_generate(uuid);
|
uuid_generate(uuid);
|
||||||
// it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null
|
// it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null
|
||||||
uuid_unparse_lower(uuid, buf);
|
uuid_unparse_lower(uuid, buf);
|
||||||
int n = tsnprintf(uid, uidlen, "%.*s", (int)sizeof(buf), buf); // though less performance, much safer
|
int n = snprintf(uid, uidlen, "%.*s", (int)sizeof(buf), buf); // though less performance, much safer
|
||||||
|
if(n >= uidlen) {
|
||||||
|
return TSDB_CODE_OUT_OF_BUFFER;;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int64_t len = 0;
|
int64_t len = 0;
|
||||||
|
|
|
@ -156,7 +156,7 @@ bool taosAnalGetOptInt(const char *option, const char *optName, int32_t *optValu
|
||||||
int32_t taosAnalGetAlgoUrl(const char *algoName, EAnalAlgoType type, char *url, int32_t urlLen) {
|
int32_t taosAnalGetAlgoUrl(const char *algoName, EAnalAlgoType type, char *url, int32_t urlLen) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char name[TSDB_ANAL_ALGO_KEY_LEN] = {0};
|
char name[TSDB_ANAL_ALGO_KEY_LEN] = {0};
|
||||||
int32_t nameLen = 1 + snprintf(name, sizeof(name) - 1, "%d:%s", type, algoName);
|
int32_t nameLen = 1 + tsnprintf(name, sizeof(name) - 1, "%d:%s", type, algoName);
|
||||||
|
|
||||||
taosThreadMutexLock(&tsAlgos.lock);
|
taosThreadMutexLock(&tsAlgos.lock);
|
||||||
SAnalUrl *pUrl = taosHashAcquire(tsAlgos.hash, name, nameLen);
|
SAnalUrl *pUrl = taosHashAcquire(tsAlgos.hash, name, nameLen);
|
||||||
|
|
Loading…
Reference in New Issue