This commit is contained in:
yihaoDeng 2024-12-09 14:48:21 +08:00
parent 32b5ec1da7
commit abc4a3768f
4 changed files with 5 additions and 5 deletions

View File

@ -251,7 +251,7 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
printf("ERROR: Encrypt key overflow, it should be at most %d characters\n", ENCRYPT_KEY_LEN); printf("ERROR: Encrypt key overflow, it should be at most %d characters\n", ENCRYPT_KEY_LEN);
return TSDB_CODE_INVALID_CFG; return TSDB_CODE_INVALID_CFG;
} }
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN); tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN + 1);
} else { } else {
printf("'-y' requires a parameter\n"); printf("'-y' requires a parameter\n");
return TSDB_CODE_INVALID_CFG; return TSDB_CODE_INVALID_CFG;

View File

@ -230,7 +230,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
} }
SCryptOpts opts; SCryptOpts opts;
tstrncpy(opts.key, key, ENCRYPT_KEY_LEN); tstrncpy(opts.key, key, ENCRYPT_KEY_LEN + 1);
opts.len = len; opts.len = len;
opts.source = DM_KEY_INDICATOR; opts.source = DM_KEY_INDICATOR;
opts.result = result; opts.result = result;
@ -349,7 +349,7 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
} }
SCryptOpts opts = {0}; SCryptOpts opts = {0};
strncpy(opts.key, key, ENCRYPT_KEY_LEN); tstrncpy(opts.key, key, ENCRYPT_KEY_LEN + 1);
opts.len = len; opts.len = len;
opts.source = content; opts.source = content;
opts.result = result; opts.result = result;

View File

@ -510,7 +510,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
opts.source = pRaw->pData; opts.source = pRaw->pData;
opts.result = newData; opts.result = newData;
opts.unitLen = 16; opts.unitLen = 16;
tstrncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN); tstrncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
int32_t count = CBC_Encrypt(&opts); int32_t count = CBC_Encrypt(&opts);

View File

@ -249,7 +249,7 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor
opts.result = PacketData; opts.result = PacketData;
opts.unitLen = 128; opts.unitLen = 128;
// strncpy(opts.key, tsEncryptKey, 16); // strncpy(opts.key, tsEncryptKey, 16);
tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN); tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN + 1);
NewLen = CBC_Decrypt(&opts); NewLen = CBC_Decrypt(&opts);