use safe sys func
This commit is contained in:
parent
66771b41a0
commit
b9d92bd7b7
|
@ -220,6 +220,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
}
|
||||
|
||||
extern SMonVloadInfo tsVinfo;
|
||||
|
||||
void dmClearVars(SDnode *pDnode) {
|
||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||
|
|
|
@ -1884,7 +1884,7 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
|||
if (strlen(pMCfgReq->value) != 0) goto _err;
|
||||
code = taosStr2int32(pMCfgReq->config + optLen + 1, pOutValue);
|
||||
if (code != 0) {
|
||||
mError("dnode:%d, failed to get cfg since code: %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
|
@ -1892,7 +1892,7 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
|||
if (strlen(pMCfgReq->value) == 0) goto _err;
|
||||
code = taosStr2int32(pMCfgReq->value, pOutValue);
|
||||
if (code != 0) {
|
||||
mError("dnode:%d, failed to get cfg since code: %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -530,7 +530,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
|||
code = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
TAOS_RETURN(code);
|
||||
} else {
|
||||
tstrncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -638,7 +638,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
|||
opts.source = newBody;
|
||||
opts.result = newBodyEncrypted;
|
||||
opts.unitLen = 16;
|
||||
tstrncpy((char *)opts.key, pWal->cfg.encryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy((char *)opts.key, pWal->cfg.encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
||||
int32_t count = CBC_Encrypt(&opts);
|
||||
|
||||
|
|
|
@ -123,10 +123,8 @@ int32_t taosStr2int64(const char *str, int64_t *val) {
|
|||
errno = 0;
|
||||
char *endptr = NULL;
|
||||
int64_t ret = strtoll(str, &endptr, 10);
|
||||
if (errno == ERANGE && (ret == LLONG_MAX || ret == LLONG_MIN)) {
|
||||
if (errno != 0) {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
} else if (errno == EINVAL && ret == 0) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
} else {
|
||||
if (endptr == str) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
|
@ -187,12 +185,11 @@ int32_t taosStr2Uint64(const char *str, uint64_t *val) {
|
|||
char *endptr = NULL;
|
||||
errno = 0;
|
||||
uint64_t ret = strtoull(str, &endptr, 10);
|
||||
if (errno == ERANGE && (ret == ULLONG_MAX)) {
|
||||
|
||||
if (errno != 0) {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
} else if (errno == EINVAL && ret == 0) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
} else {
|
||||
if (str == endptr) {
|
||||
if (endptr == str) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
*val = ret;
|
||||
|
|
|
@ -283,30 +283,25 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value,
|
|||
tstrncpy(cfg.dir, pItem->str, sizeof(cfg.dir));
|
||||
|
||||
code = taosStr2int32(level, &cfg.level);
|
||||
if (code != 0) {
|
||||
cfg.level = 0;
|
||||
}
|
||||
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||
code = taosStr2int32(primary, &cfg.primary);
|
||||
if (code != 0) {
|
||||
cfg.primary = 1;
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||
code = taosStr2int8(disable, &cfg.disable);
|
||||
if (code != 0) {
|
||||
cfg.disable = 0;
|
||||
}
|
||||
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||
|
||||
void *ret = taosArrayPush(pItem->array, &cfg);
|
||||
if (ret == NULL) {
|
||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||
|
||||
TAOS_RETURN(terrno);
|
||||
code = terrno;
|
||||
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||
}
|
||||
|
||||
pItem->stype = stype;
|
||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
_err:
|
||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool resetArray) {
|
||||
|
|
Loading…
Reference in New Issue