Blame SOURCES/openssl-fips-0.9.8e-cve-2009-4355.patch

5820f5
Modify compression code so it frees up structures without using the
5820f5
ex_data callbacks. This works around a problem where some applications
5820f5
call CRYPTO_free_all_ex_data() before application exit (e.g. when
5820f5
restarting) then use compression (e.g. SSL with compression) later.
5820f5
This results in significant per-connection memory leaks and
5820f5
has caused some security issues including CVE-2008-1678 and
5820f5
CVE-2009-4355. [Steve Henson]
5820f5
diff -up openssl-fips-0.9.8e/crypto/comp/c_zlib.c.compleak openssl-fips-0.9.8e/crypto/comp/c_zlib.c
5820f5
--- openssl-fips-0.9.8e/crypto/comp/c_zlib.c.compleak	2007-02-14 22:50:26.000000000 +0100
5820f5
+++ openssl-fips-0.9.8e/crypto/comp/c_zlib.c	2010-01-14 09:32:46.000000000 +0100
5820f5
@@ -133,15 +133,6 @@ struct zlib_state
5820f5
 
5820f5
 static int zlib_stateful_ex_idx = -1;
5820f5
 
5820f5
-static void zlib_stateful_free_ex_data(void *obj, void *item,
5820f5
-	CRYPTO_EX_DATA *ad, int ind,long argl, void *argp)
5820f5
-	{
5820f5
-	struct zlib_state *state = (struct zlib_state *)item;
5820f5
-	inflateEnd(&state->istream);
5820f5
-	deflateEnd(&state->ostream);
5820f5
-	OPENSSL_free(state);
5820f5
-	}
5820f5
-
5820f5
 static int zlib_stateful_init(COMP_CTX *ctx)
5820f5
 	{
5820f5
 	int err;
5820f5
@@ -185,6 +176,12 @@ static int zlib_stateful_init(COMP_CTX *
5820f5
 
5820f5
 static void zlib_stateful_finish(COMP_CTX *ctx)
5820f5
 	{
5820f5
+	struct zlib_state *state =
5820f5
+		(struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data,
5820f5
+			zlib_stateful_ex_idx);
5820f5
+	inflateEnd(&state->istream);
5820f5
+	deflateEnd(&state->ostream);
5820f5
+	OPENSSL_free(state);
5820f5
 	CRYPTO_free_ex_data(CRYPTO_EX_INDEX_COMP,ctx,&ctx->ex_data);
5820f5
 	}
5820f5
 
5820f5
@@ -396,7 +393,7 @@ COMP_METHOD *COMP_zlib(void)
5820f5
 			if (zlib_stateful_ex_idx == -1)
5820f5
 				zlib_stateful_ex_idx =
5820f5
 					CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP,
5820f5
-						0,NULL,NULL,NULL,zlib_stateful_free_ex_data);
5820f5
+						0,NULL,NULL,NULL,NULL);
5820f5
 			CRYPTO_w_unlock(CRYPTO_LOCK_COMP);
5820f5
 			if (zlib_stateful_ex_idx == -1)
5820f5
 				goto err;