SKALE-3374 fix leak

parent 6ff6f483
......@@ -166,8 +166,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
CHECK_STATE(_hashHex);
CHECK_STATE(_sig);
auto hash = make_shared < array < uint8_t,
32 >> ();
auto hash = make_shared < array < uint8_t, 32 >> ();
uint64_t binLen;
......
......@@ -82,8 +82,8 @@ string *stringFromFq(libff::alt_bn128_Fq *_fq) {
try {
_fq->as_bigint().to_mpz(t);
char *tmp = mpz_get_str(arr, 10, t);
ret = new string(tmp);
mpz_get_str(arr, 10, t);
ret = new string(arr);
} catch (exception &e) {
LOG_ERROR(e.what());
goto clean;
......@@ -107,13 +107,13 @@ string *stringFromG1(libff::alt_bn128_G1 *_g1) {
try {
_g1->to_affine_coordinates();
auto sX = stringFromFq(&_g1->X);
sX = stringFromFq(&_g1->X);
if (!sX) {
goto clean;
}
auto sY = stringFromFq(&_g1->Y);
sY = stringFromFq(&_g1->Y);
if (!sY) {
goto clean;
......@@ -131,8 +131,8 @@ string *stringFromG1(libff::alt_bn128_G1 *_g1) {
clean:
SAFE_FREE(sX);
SAFE_FREE(sY);
SAFE_DELETE(sX);
SAFE_DELETE(sY);
return ret;
......@@ -226,7 +226,7 @@ bool enclave_sign(const char *_keyString, const char *_hashXString, const char *
}
try {
auto key = keyFromString(_keyString);
key = keyFromString(_keyString);
if (!key) {
LOG_ERROR("Null key");
......@@ -243,13 +243,13 @@ bool enclave_sign(const char *_keyString, const char *_hashXString, const char *
sign.to_affine_coordinates();
auto r = stringFromG1(&sign);
r = stringFromG1(&sign);
memset(sig, 0, BUF_LEN);
strncpy(sig, r->c_str(), BUF_LEN);
ret = true;
ret = true;
} catch (exception &e) {
LOG_ERROR(e.what());
......
......@@ -1118,8 +1118,6 @@ trustedGetBlsPubKey(int *errStatus, char *errString, uint8_t *encryptedPrivateKe
uint8_t type = 0;
uint8_t exportable = 0;
int status = AES_decrypt(encryptedPrivateKey, key_len, skey_hex, BUF_LEN,
&type, &exportable);
......
......@@ -657,8 +657,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
string hash = SAMPLE_HASH;
auto hash_arr = make_shared < array < uint8_t,
32 >> ();
auto hash_arr = make_shared < array < uint8_t, 32 >> ();
uint64_t binLen;
......@@ -723,8 +722,8 @@ TEST_CASE_METHOD(TestFixture, "AES encrypt/decrypt", "[aes-encrypt-decrypt]") {
status = trustedDecryptKey(eid, &errStatus, errMsg.data(), encrypted_key.data(), encLen, decr_key.data());
REQUIRE(status == 0);
REQUIRE(errStatus == 0);
REQUIRE(key.compare(decr_key.data()) == 0);
REQUIRE(errStatus == 0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment