@cryptotaxi247 / netdata-1 / commits / 7e2430cb0

Free context when establishing ACLK connection (#15073)

Free context

Stelios Fragkakis committed May 19, 2023 at 09:31 UTC 7e2430cb0217eeb3a1d442b0709174ab54738dac
1 file changed +8 -2
aclk/aclk_otp.c
+8 -2
@@ -444,11 +444,15 @@ static int private_decrypt(RSA *p_key, unsigned char * enc_data, int data_len, u
444 if (!ctx)
445 return 1;
446
447 - if (EVP_PKEY_decrypt_init(ctx) <= 0)
447 + if (EVP_PKEY_decrypt_init(ctx) <= 0) {
448 + EVP_PKEY_CTX_free(ctx);
449 return 1;
450 + }
451
450 - if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING) <= 0)
452 + if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING) <= 0) {
453 + EVP_PKEY_CTX_free(ctx);
454 return 1;
455 + }
456
457 *decrypted = mallocz(outlen);
458
@@ -456,6 +460,8 @@ static int private_decrypt(RSA *p_key, unsigned char * enc_data, int data_len, u
460 result = (int) outlen;
461 else
462 result = -1;
463 +
464 + EVP_PKEY_CTX_free(ctx);
465 #else
466 *decrypted = mallocz(RSA_size(p_key));
467 result = RSA_private_decrypt(data_len, enc_data, *decrypted, p_key, RSA_PKCS1_OAEP_PADDING);