enh: memory safe function
This commit is contained in:
parent
80d69d4c1c
commit
9fd2d86ae3
|
@ -26,7 +26,7 @@ typedef struct SCryptOpts {
|
|||
char* source;
|
||||
char* result;
|
||||
int32_t unitLen;
|
||||
char key[17];
|
||||
char key[ENCRYPT_KEY_LEN + 1];
|
||||
} SCryptOpts;
|
||||
|
||||
int32_t CBC_Decrypt(SCryptOpts* opts);
|
||||
|
|
|
@ -211,7 +211,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
#if defined(TD_ENTERPRISE)
|
||||
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
#else
|
||||
pCfg->tdbEncryptAlgorithm = 0;
|
||||
|
|
|
@ -327,7 +327,7 @@ struct SVnodeCfg {
|
|||
int16_t hashSuffix;
|
||||
int32_t tsdbPageSize;
|
||||
int32_t tdbEncryptAlgorithm;
|
||||
char tdbEncryptKey[ENCRYPT_KEY_LEN];
|
||||
char tdbEncryptKey[ENCRYPT_KEY_LEN + 1];
|
||||
int32_t s3ChunkSize;
|
||||
int32_t s3KeepLocal;
|
||||
int8_t s3Compact;
|
||||
|
|
|
@ -303,7 +303,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (tsEncryptKey[0] == 0) {
|
||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
} else {
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue