Merge pull request #29185 from taosdata/enh/TD-32406-main
enh: memory safe function
This commit is contained in:
commit
3497aab1d6
|
@ -26,7 +26,7 @@ typedef struct SCryptOpts {
|
||||||
char* source;
|
char* source;
|
||||||
char* result;
|
char* result;
|
||||||
int32_t unitLen;
|
int32_t unitLen;
|
||||||
char key[17];
|
char key[ENCRYPT_KEY_LEN + 1];
|
||||||
} SCryptOpts;
|
} SCryptOpts;
|
||||||
|
|
||||||
int32_t CBC_Decrypt(SCryptOpts* opts);
|
int32_t CBC_Decrypt(SCryptOpts* opts);
|
||||||
|
|
|
@ -211,7 +211,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
#if defined(TD_ENTERPRISE)
|
#if defined(TD_ENTERPRISE)
|
||||||
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
|
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
|
||||||
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
|
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
|
||||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
pCfg->tdbEncryptAlgorithm = 0;
|
pCfg->tdbEncryptAlgorithm = 0;
|
||||||
|
|
|
@ -327,7 +327,7 @@ struct SVnodeCfg {
|
||||||
int16_t hashSuffix;
|
int16_t hashSuffix;
|
||||||
int32_t tsdbPageSize;
|
int32_t tsdbPageSize;
|
||||||
int32_t tdbEncryptAlgorithm;
|
int32_t tdbEncryptAlgorithm;
|
||||||
char tdbEncryptKey[ENCRYPT_KEY_LEN];
|
char tdbEncryptKey[ENCRYPT_KEY_LEN + 1];
|
||||||
int32_t s3ChunkSize;
|
int32_t s3ChunkSize;
|
||||||
int32_t s3KeepLocal;
|
int32_t s3KeepLocal;
|
||||||
int8_t s3Compact;
|
int8_t s3Compact;
|
||||||
|
|
|
@ -104,7 +104,7 @@ int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbFD **ppF
|
||||||
}
|
}
|
||||||
|
|
||||||
pFD->path = (char *)&pFD[1];
|
pFD->path = (char *)&pFD[1];
|
||||||
tstrncpy(pFD->path, path, strlen(path) + 1);
|
memcpy(pFD->path, path, strlen(path) + 1);
|
||||||
pFD->szPage = szPage;
|
pFD->szPage = szPage;
|
||||||
pFD->flag = flag;
|
pFD->flag = flag;
|
||||||
pFD->szPage = szPage;
|
pFD->szPage = szPage;
|
||||||
|
|
|
@ -330,7 +330,7 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
tstrncpy((char *)((*async) + 1), label, strlen(label) + 1);
|
memcpy((char *)((*async) + 1), label, strlen(label) + 1);
|
||||||
(*async)->label = (const char *)((*async) + 1);
|
(*async)->label = (const char *)((*async) + 1);
|
||||||
|
|
||||||
(void)taosThreadMutexInit(&(*async)->mutex, NULL);
|
(void)taosThreadMutexInit(&(*async)->mutex, NULL);
|
||||||
|
|
|
@ -303,7 +303,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
if (tsEncryptKey[0] == 0) {
|
if (tsEncryptKey[0] == 0) {
|
||||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
} else {
|
} else {
|
||||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -417,7 +417,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->path = (char *)&pVnode[1];
|
pVnode->path = (char *)&pVnode[1];
|
||||||
tstrncpy(pVnode->path, path, strlen(path) + 1);
|
memcpy(pVnode->path, path, strlen(path) + 1);
|
||||||
pVnode->config = info.config;
|
pVnode->config = info.config;
|
||||||
pVnode->state.committed = info.state.committed;
|
pVnode->state.committed = info.state.committed;
|
||||||
pVnode->state.commitTerm = info.state.commitTerm;
|
pVnode->state.commitTerm = info.state.commitTerm;
|
||||||
|
|
Loading…
Reference in New Issue