From: Richard Levitte Date: Tue, 12 Apr 2016 14:12:53 +0000 (+0200) Subject: Remake the way dynamic zlib is loaded X-Git-Tag: OpenSSL_1_1_0-pre5~51 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5a5c0b953f8f97b4e604da494a65de034bbaaceb;p=oweals%2Fopenssl.git Remake the way dynamic zlib is loaded Instead of absolute hard coding of the libz library name, have it use the macro LIBZ, which is set to defaults we know in case it's undefined. This allows our configuration to set something that's sane on current or older platforms, and allows the user to override it by defining LIBZ themselves. Reviewed-by: Matt Caswell --- diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 8c6ee7f0e3..5bf8a0df70 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -1249,6 +1249,14 @@ sub vms_info { template => 1, cc => "cl", cflags => "-W3 -wd4090 -Gs0 -GF -Gy -nologo -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE", + defines => add(sub { my @defs = (); + unless ($disabled{"zlib-dynamic"}) { + push @defs, + quotify("perl", + 'LIBZ="' . $withargs{zlib_lib} . '"'); + } + return [ @defs ]; + }), coutflag => "/Fo", rc => "rc", rcoutflag => "/fo", diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c index 20376b6451..6dd76846c5 100644 --- a/crypto/comp/c_zlib.c +++ b/crypto/comp/c_zlib.c @@ -256,12 +256,19 @@ COMP_METHOD *COMP_zlib(void) COMP_METHOD *meth = &zlib_method_nozlib; #ifdef ZLIB_SHARED - if (!zlib_loaded) { -# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) - zlib_dso = DSO_load(NULL, "ZLIB1", NULL, 0); -# else - zlib_dso = DSO_load(NULL, "z", NULL, 0); + /* LIBZ may be externally defined, and we should respect that value */ +# ifndef LIBZ +# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) +# define LIBZ "ZLIB1" +# elif defined(OPENSSL_SYS_VMS) +# define LIBZ "LIBZ" +# else +# define LIBZ "z" +# endif # endif + + if (!zlib_loaded) { + zlib_dso = DSO_load(NULL, LIBZ, NULL, 0); if (zlib_dso != NULL) { p_compress = (compress_ft) DSO_bind_func(zlib_dso, "compress"); p_inflateEnd