Fix memory leak in digestmd5 patches
Signed-off-by: Simo Sorce <simo@redhat.com>
This commit is contained in:
parent
b96caf4432
commit
a64513daf1
@ -105,7 +105,7 @@ diff -uPr cyrus-sasl-2.1.27/plugins/digestmd5.c cyrus-sasl-2.1.27.digestmd5/plug
|
|||||||
|
|
||||||
/* setup dec context */
|
/* setup dec context */
|
||||||
c++;
|
c++;
|
||||||
@@ -1102,60 +1114,139 @@
|
@@ -1102,60 +1114,143 @@
|
||||||
|
|
||||||
memcpy(c->ivec, ((char *) deckey) + 8, 8);
|
memcpy(c->ivec, ((char *) deckey) + 8, 8);
|
||||||
|
|
||||||
@ -204,13 +204,13 @@ diff -uPr cyrus-sasl-2.1.27/plugins/digestmd5.c cyrus-sasl-2.1.27.digestmd5/plug
|
|||||||
unsigned char enckey[16],
|
unsigned char enckey[16],
|
||||||
unsigned char deckey[16])
|
unsigned char deckey[16])
|
||||||
{
|
{
|
||||||
+ const EVP_CIPHER *cipher;
|
|
||||||
EVP_CIPHER_CTX *ctx;
|
EVP_CIPHER_CTX *ctx;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
- ctx = EVP_CIPHER_CTX_new();
|
- ctx = EVP_CIPHER_CTX_new();
|
||||||
- if (ctx == NULL) return SASL_NOMEM;
|
- if (ctx == NULL) return SASL_NOMEM;
|
||||||
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||||
|
+ EVP_CIPHER *cipher;
|
||||||
+ ossl3_context_t *ossl3_ctx;
|
+ ossl3_context_t *ossl3_ctx;
|
||||||
|
|
||||||
- rc = EVP_EncryptInit_ex(ctx, EVP_rc4(), NULL, enckey, NULL);
|
- rc = EVP_EncryptInit_ex(ctx, EVP_rc4(), NULL, enckey, NULL);
|
||||||
@ -221,6 +221,7 @@ diff -uPr cyrus-sasl-2.1.27/plugins/digestmd5.c cyrus-sasl-2.1.27.digestmd5/plug
|
|||||||
+ ossl3_ctx = (ossl3_context_t *)text->crypto.libctx;
|
+ ossl3_ctx = (ossl3_context_t *)text->crypto.libctx;
|
||||||
+ cipher = EVP_CIPHER_fetch(ossl3_ctx->libctx, "RC4", "");
|
+ cipher = EVP_CIPHER_fetch(ossl3_ctx->libctx, "RC4", "");
|
||||||
+#else
|
+#else
|
||||||
|
+ const EVP_CIPHER *cipher;
|
||||||
+ cipher = EVP_rc4();
|
+ cipher = EVP_rc4();
|
||||||
+#endif
|
+#endif
|
||||||
|
|
||||||
@ -260,6 +261,9 @@ diff -uPr cyrus-sasl-2.1.27/plugins/digestmd5.c cyrus-sasl-2.1.27.digestmd5/plug
|
|||||||
+ rc = SASL_OK;
|
+ rc = SASL_OK;
|
||||||
+
|
+
|
||||||
+done:
|
+done:
|
||||||
|
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||||
|
+ EVP_CIPHER_free(cipher);
|
||||||
|
+#endif
|
||||||
+ if (rc != SASL_OK) {
|
+ if (rc != SASL_OK) {
|
||||||
+ free_rc4(text);
|
+ free_rc4(text);
|
||||||
+ }
|
+ }
|
||||||
|
Loading…
Reference in New Issue
Block a user