From b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 Mon Sep 17 00:00:00 2001 From: beck <> Date: Wed, 15 May 2002 02:29:21 +0000 Subject: OpenSSL 0.9.7 stable 2002 05 08 merge --- src/lib/libcrypto/comp/Makefile.ssl | 46 +++++++----- src/lib/libcrypto/comp/c_rle.c | 1 + src/lib/libcrypto/comp/c_zlib.c | 141 ++++++++++++++++++++++++++++++++++-- src/lib/libcrypto/comp/comp.h | 4 +- src/lib/libcrypto/comp/comp_err.c | 4 +- 5 files changed, 167 insertions(+), 29 deletions(-) (limited to 'src/lib/libcrypto/comp') diff --git a/src/lib/libcrypto/comp/Makefile.ssl b/src/lib/libcrypto/comp/Makefile.ssl index b696ac75fe..5dadb65cd4 100644 --- a/src/lib/libcrypto/comp/Makefile.ssl +++ b/src/lib/libcrypto/comp/Makefile.ssl @@ -5,13 +5,14 @@ DIR= comp TOP= ../.. CC= cc -INCLUDES= -I.. -I../../include +INCLUDES= -I.. -I$(TOP) -I../../include CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl MAKE= make -f Makefile.ssl -MAKEDEPEND= $(TOP)/util/domd $(TOP) +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) MAKEFILE= Makefile.ssl AR= ar r @@ -22,10 +23,10 @@ TEST= APPS= LIB=$(TOP)/libcrypto.a -LIBSRC= comp_lib.c \ +LIBSRC= comp_lib.c comp_err.c \ c_rle.c c_zlib.c -LIBOBJ= comp_lib.o \ +LIBOBJ= comp_lib.o comp_err.o \ c_rle.o c_zlib.o SRC= $(LIBSRC) @@ -42,8 +43,7 @@ all: lib lib: $(LIBOBJ) $(AR) $(LIB) $(LIBOBJ) - @echo You may get an error following this line. Please ignore. - - $(RANLIB) $(LIB) + $(RANLIB) $(LIB) || echo Never mind. @touch lib files: @@ -84,19 +84,31 @@ clean: c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h -c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h -c_rle.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h -c_rle.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +c_rle.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +c_rle.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +c_rle.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h +c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h c_rle.c c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h -c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h -c_zlib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h -c_zlib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +c_zlib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +c_zlib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +c_zlib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h c_zlib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +c_zlib.o: c_zlib.c +comp_err.o: ../../include/openssl/bio.h ../../include/openssl/comp.h +comp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +comp_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h +comp_err.o: ../../include/openssl/opensslconf.h +comp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +comp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +comp_err.o: comp_err.c comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h -comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h -comp_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h -comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -comp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +comp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +comp_lib.o: ../../include/openssl/opensslconf.h +comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +comp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +comp_lib.o: ../../include/openssl/symhacks.h comp_lib.c diff --git a/src/lib/libcrypto/comp/c_rle.c b/src/lib/libcrypto/comp/c_rle.c index 1a819e3737..efd366fa22 100644 --- a/src/lib/libcrypto/comp/c_rle.c +++ b/src/lib/libcrypto/comp/c_rle.c @@ -17,6 +17,7 @@ static COMP_METHOD rle_method={ rle_compress_block, rle_expand_block, NULL, + NULL, }; COMP_METHOD *COMP_rle(void) diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c index 6684ab4841..cd2f8a491b 100644 --- a/src/lib/libcrypto/comp/c_zlib.c +++ b/src/lib/libcrypto/comp/c_zlib.c @@ -6,11 +6,10 @@ COMP_METHOD *COMP_zlib(void ); -#ifndef ZLIB - -static COMP_METHOD zlib_method={ +static COMP_METHOD zlib_method_nozlib={ NID_undef, - "(null)", + "(undef)", + NULL, NULL, NULL, NULL, @@ -18,6 +17,8 @@ static COMP_METHOD zlib_method={ NULL, }; +#ifndef ZLIB +#undef ZLIB_SHARED #else #include @@ -38,8 +39,56 @@ static COMP_METHOD zlib_method={ zlib_compress_block, zlib_expand_block, NULL, + NULL, }; +/* + * When OpenSSL is built on Windows, we do not want to require that + * the ZLIB.DLL be available in order for the OpenSSL DLLs to + * work. Therefore, all ZLIB routines are loaded at run time + * and we do not link to a .LIB file. + */ +#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) +# include + +# define Z_CALLCONV _stdcall +# define ZLIB_SHARED +#else +# define Z_CALLCONV +#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */ + +#ifdef ZLIB_SHARED +#include + +/* Prototypes for built in stubs */ +static int stub_compress(Bytef *dest,uLongf *destLen, + const Bytef *source, uLong sourceLen); +static int stub_inflateEnd(z_streamp strm); +static int stub_inflate(z_streamp strm, int flush); +static int stub_inflateInit_(z_streamp strm, const char * version, + int stream_size); + +/* Function pointers */ +typedef int (Z_CALLCONV *compress_ft)(Bytef *dest,uLongf *destLen, + const Bytef *source, uLong sourceLen); +typedef int (Z_CALLCONV *inflateEnd_ft)(z_streamp strm); +typedef int (Z_CALLCONV *inflate_ft)(z_streamp strm, int flush); +typedef int (Z_CALLCONV *inflateInit__ft)(z_streamp strm, + const char * version, int stream_size); +static compress_ft p_compress=NULL; +static inflateEnd_ft p_inflateEnd=NULL; +static inflate_ft p_inflate=NULL; +static inflateInit__ft p_inflateInit_=NULL; + +static int zlib_loaded = 0; /* only attempt to init func pts once */ +static DSO *zlib_dso = NULL; + +#define compress stub_compress +#define inflateEnd stub_inflateEnd +#define inflate stub_inflate +#define inflateInit_ stub_inflateInit_ +#endif /* ZLIB_SHARED */ + static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen) { @@ -66,7 +115,10 @@ static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, memcpy(&(out[1]),in,ilen); l=ilen+1; } -fprintf(stderr,"compress(%4d)->%4d %s\n",ilen,(int)l,(clear)?"clear":"zlib"); +#ifdef DEBUG_ZLIB + fprintf(stderr,"compress(%4d)->%4d %s\n", + ilen,(int)l,(clear)?"clear":"zlib"); +#endif return((int)l); } @@ -88,7 +140,10 @@ static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, memcpy(out,&(in[1]),ilen-1); l=ilen-1; } - fprintf(stderr,"expand (%4d)->%4d %s\n",ilen,(int)l,in[0]?"zlib":"clear"); +#ifdef DEBUG_ZLIB + fprintf(stderr,"expand (%4d)->%4d %s\n", + ilen,(int)l,in[0]?"zlib":"clear"); +#endif return((int)l); } @@ -128,6 +183,78 @@ static int zz_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, COMP_METHOD *COMP_zlib(void) { - return(&zlib_method); + 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, "ZLIB", NULL, 0); +#else + zlib_dso = DSO_load(NULL, "z", NULL, 0); +#endif + if (zlib_dso != NULL) + { + p_compress + = (compress_ft) DSO_bind_func(zlib_dso, + "compress"); + p_inflateEnd + = (inflateEnd_ft) DSO_bind_func(zlib_dso, + "inflateEnd"); + p_inflate + = (inflate_ft) DSO_bind_func(zlib_dso, + "inflate"); + p_inflateInit_ + = (inflateInit__ft) DSO_bind_func(zlib_dso, + "inflateInit_"); + zlib_loaded++; + meth = &zlib_method; + } + } + +#elif defined(ZLIB) + meth = &zlib_method; +#endif + + return(meth); + } + +#ifdef ZLIB_SHARED +/* Stubs for each function to be dynamicly loaded */ +static int +stub_compress(Bytef *dest,uLongf *destLen,const Bytef *source, uLong sourceLen) + { + if (p_compress) + return(p_compress(dest,destLen,source,sourceLen)); + else + return(Z_MEM_ERROR); + } + +static int +stub_inflateEnd(z_streamp strm) + { + if ( p_inflateEnd ) + return(p_inflateEnd(strm)); + else + return(Z_MEM_ERROR); + } + +static int +stub_inflate(z_streamp strm, int flush) + { + if ( p_inflate ) + return(p_inflate(strm,flush)); + else + return(Z_MEM_ERROR); + } + +static int +stub_inflateInit_(z_streamp strm, const char * version, int stream_size) + { + if ( p_inflateInit_ ) + return(p_inflateInit_(strm,version,stream_size)); + else + return(Z_MEM_ERROR); } +#endif /* ZLIB_SHARED */ diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h index 0922609542..ab48b78ae9 100644 --- a/src/lib/libcrypto/comp/comp.h +++ b/src/lib/libcrypto/comp/comp.h @@ -39,14 +39,13 @@ int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, unsigned char *in, int ilen); COMP_METHOD *COMP_rle(void ); -#ifdef ZLIB COMP_METHOD *COMP_zlib(void ); -#endif /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. */ +void ERR_load_COMP_strings(void); /* Error codes for the COMP functions. */ @@ -58,4 +57,3 @@ COMP_METHOD *COMP_zlib(void ); } #endif #endif - diff --git a/src/lib/libcrypto/comp/comp_err.c b/src/lib/libcrypto/comp/comp_err.c index c10282a73c..1652b8c2c4 100644 --- a/src/lib/libcrypto/comp/comp_err.c +++ b/src/lib/libcrypto/comp/comp_err.c @@ -63,7 +63,7 @@ #include /* BEGIN ERROR CODES */ -#ifndef NO_ERR +#ifndef OPENSSL_NO_ERR static ERR_STRING_DATA COMP_str_functs[]= { {0,NULL} @@ -83,7 +83,7 @@ void ERR_load_COMP_strings(void) if (init) { init=0; -#ifndef NO_ERR +#ifndef OPENSSL_NO_ERR ERR_load_strings(ERR_LIB_COMP,COMP_str_functs); ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons); #endif -- cgit v1.2.3-55-g6feb