038bb32
diff -up openssl-1.0.2a/doc/ssl/SSL_COMP_add_compression_method.pod.env-zlib openssl-1.0.2a/doc/ssl/SSL_COMP_add_compression_method.pod
038bb32
--- openssl-1.0.2a/doc/ssl/SSL_COMP_add_compression_method.pod.env-zlib	2015-04-09 18:17:20.509637597 +0200
038bb32
+++ openssl-1.0.2a/doc/ssl/SSL_COMP_add_compression_method.pod	2015-04-09 18:17:14.767504953 +0200
ec2806a
@@ -47,6 +47,13 @@ Once the identities of the compression m
ec2806a
 been standardized, the compression API will most likely be changed. Using
ec2806a
 it in the current state is not recommended.
ec2806a
 
ec2806a
+It is also not recommended to use compression if data transfered contain
ec2806a
+untrusted parts that can be manipulated by an attacker as he could then
ec2806a
+get information about the encrypted data. See the CRIME attack. For
ec2806a
+that reason the default loading of the zlib compression method is
ec2806a
+disabled and enabled only if the environment variable B<OPENSSL_DEFAULT_ZLIB>
ec2806a
+is present during the library initialization.
ec2806a
+
ec2806a
 =head1 RETURN VALUES
ec2806a
 
ec2806a
 SSL_COMP_add_compression_method() may return the following values:
038bb32
diff -up openssl-1.0.2a/ssl/ssl_ciph.c.env-zlib openssl-1.0.2a/ssl/ssl_ciph.c
038bb32
--- openssl-1.0.2a/ssl/ssl_ciph.c.env-zlib	2015-04-09 18:17:20.510637620 +0200
038bb32
+++ openssl-1.0.2a/ssl/ssl_ciph.c	2015-04-09 18:17:20.264631937 +0200
ec2806a
@@ -140,6 +140,8 @@
ec2806a
  * OTHERWISE.
ec2806a
  */
ec2806a
 
ec2806a
+/* for secure_getenv */
ec2806a
+#define _GNU_SOURCE
ec2806a
 #include <stdio.h>
ec2806a
 #include <openssl/objects.h>
ec2806a
 #ifndef OPENSSL_NO_COMP
038bb32
@@ -450,7 +452,8 @@ static void load_builtin_compressions(vo
ec2806a
 
038bb32
             MemCheck_off();
038bb32
             ssl_comp_methods = sk_SSL_COMP_new(sk_comp_cmp);
038bb32
-            if (ssl_comp_methods != NULL) {
038bb32
+            if (ssl_comp_methods != NULL
038bb32
+                && secure_getenv("OPENSSL_DEFAULT_ZLIB") != NULL) {
038bb32
                 comp = (SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP));
038bb32
                 if (comp != NULL) {
038bb32
                     comp->method = COMP_zlib();