diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/comp/c_rle.c | 1 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/c_zlib.c | 141 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp.h | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp_err.c | 7 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp_lib.c | 6 |
5 files changed, 146 insertions, 18 deletions
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={ | |||
| 17 | rle_compress_block, | 17 | rle_compress_block, |
| 18 | rle_expand_block, | 18 | rle_expand_block, |
| 19 | NULL, | 19 | NULL, |
| 20 | NULL, | ||
| 20 | }; | 21 | }; |
| 21 | 22 | ||
| 22 | COMP_METHOD *COMP_rle(void) | 23 | 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 @@ | |||
| 6 | 6 | ||
| 7 | COMP_METHOD *COMP_zlib(void ); | 7 | COMP_METHOD *COMP_zlib(void ); |
| 8 | 8 | ||
| 9 | #ifndef ZLIB | 9 | static COMP_METHOD zlib_method_nozlib={ |
| 10 | |||
| 11 | static COMP_METHOD zlib_method={ | ||
| 12 | NID_undef, | 10 | NID_undef, |
| 13 | "(null)", | 11 | "(undef)", |
| 12 | NULL, | ||
| 14 | NULL, | 13 | NULL, |
| 15 | NULL, | 14 | NULL, |
| 16 | NULL, | 15 | NULL, |
| @@ -18,6 +17,8 @@ static COMP_METHOD zlib_method={ | |||
| 18 | NULL, | 17 | NULL, |
| 19 | }; | 18 | }; |
| 20 | 19 | ||
| 20 | #ifndef ZLIB | ||
| 21 | #undef ZLIB_SHARED | ||
| 21 | #else | 22 | #else |
| 22 | 23 | ||
| 23 | #include <zlib.h> | 24 | #include <zlib.h> |
| @@ -38,8 +39,56 @@ static COMP_METHOD zlib_method={ | |||
| 38 | zlib_compress_block, | 39 | zlib_compress_block, |
| 39 | zlib_expand_block, | 40 | zlib_expand_block, |
| 40 | NULL, | 41 | NULL, |
| 42 | NULL, | ||
| 41 | }; | 43 | }; |
| 42 | 44 | ||
| 45 | /* | ||
| 46 | * When OpenSSL is built on Windows, we do not want to require that | ||
| 47 | * the ZLIB.DLL be available in order for the OpenSSL DLLs to | ||
| 48 | * work. Therefore, all ZLIB routines are loaded at run time | ||
| 49 | * and we do not link to a .LIB file. | ||
| 50 | */ | ||
| 51 | #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) | ||
| 52 | # include <windows.h> | ||
| 53 | |||
| 54 | # define Z_CALLCONV _stdcall | ||
| 55 | # define ZLIB_SHARED | ||
| 56 | #else | ||
| 57 | # define Z_CALLCONV | ||
| 58 | #endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */ | ||
| 59 | |||
| 60 | #ifdef ZLIB_SHARED | ||
| 61 | #include <openssl/dso.h> | ||
| 62 | |||
| 63 | /* Prototypes for built in stubs */ | ||
| 64 | static int stub_compress(Bytef *dest,uLongf *destLen, | ||
| 65 | const Bytef *source, uLong sourceLen); | ||
| 66 | static int stub_inflateEnd(z_streamp strm); | ||
| 67 | static int stub_inflate(z_streamp strm, int flush); | ||
| 68 | static int stub_inflateInit_(z_streamp strm, const char * version, | ||
| 69 | int stream_size); | ||
| 70 | |||
| 71 | /* Function pointers */ | ||
| 72 | typedef int (Z_CALLCONV *compress_ft)(Bytef *dest,uLongf *destLen, | ||
| 73 | const Bytef *source, uLong sourceLen); | ||
| 74 | typedef int (Z_CALLCONV *inflateEnd_ft)(z_streamp strm); | ||
| 75 | typedef int (Z_CALLCONV *inflate_ft)(z_streamp strm, int flush); | ||
| 76 | typedef int (Z_CALLCONV *inflateInit__ft)(z_streamp strm, | ||
| 77 | const char * version, int stream_size); | ||
| 78 | static compress_ft p_compress=NULL; | ||
| 79 | static inflateEnd_ft p_inflateEnd=NULL; | ||
| 80 | static inflate_ft p_inflate=NULL; | ||
| 81 | static inflateInit__ft p_inflateInit_=NULL; | ||
| 82 | |||
| 83 | static int zlib_loaded = 0; /* only attempt to init func pts once */ | ||
| 84 | static DSO *zlib_dso = NULL; | ||
| 85 | |||
| 86 | #define compress stub_compress | ||
| 87 | #define inflateEnd stub_inflateEnd | ||
| 88 | #define inflate stub_inflate | ||
| 89 | #define inflateInit_ stub_inflateInit_ | ||
| 90 | #endif /* ZLIB_SHARED */ | ||
| 91 | |||
| 43 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | 92 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, |
| 44 | unsigned int olen, unsigned char *in, unsigned int ilen) | 93 | unsigned int olen, unsigned char *in, unsigned int ilen) |
| 45 | { | 94 | { |
| @@ -66,7 +115,10 @@ static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | |||
| 66 | memcpy(&(out[1]),in,ilen); | 115 | memcpy(&(out[1]),in,ilen); |
| 67 | l=ilen+1; | 116 | l=ilen+1; |
| 68 | } | 117 | } |
| 69 | fprintf(stderr,"compress(%4d)->%4d %s\n",ilen,(int)l,(clear)?"clear":"zlib"); | 118 | #ifdef DEBUG_ZLIB |
| 119 | fprintf(stderr,"compress(%4d)->%4d %s\n", | ||
| 120 | ilen,(int)l,(clear)?"clear":"zlib"); | ||
| 121 | #endif | ||
| 70 | return((int)l); | 122 | return((int)l); |
| 71 | } | 123 | } |
| 72 | 124 | ||
| @@ -88,7 +140,10 @@ static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, | |||
| 88 | memcpy(out,&(in[1]),ilen-1); | 140 | memcpy(out,&(in[1]),ilen-1); |
| 89 | l=ilen-1; | 141 | l=ilen-1; |
| 90 | } | 142 | } |
| 91 | fprintf(stderr,"expand (%4d)->%4d %s\n",ilen,(int)l,in[0]?"zlib":"clear"); | 143 | #ifdef DEBUG_ZLIB |
| 144 | fprintf(stderr,"expand (%4d)->%4d %s\n", | ||
| 145 | ilen,(int)l,in[0]?"zlib":"clear"); | ||
| 146 | #endif | ||
| 92 | return((int)l); | 147 | return((int)l); |
| 93 | } | 148 | } |
| 94 | 149 | ||
| @@ -128,6 +183,78 @@ static int zz_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, | |||
| 128 | 183 | ||
| 129 | COMP_METHOD *COMP_zlib(void) | 184 | COMP_METHOD *COMP_zlib(void) |
| 130 | { | 185 | { |
| 131 | return(&zlib_method); | 186 | COMP_METHOD *meth = &zlib_method_nozlib; |
| 187 | |||
| 188 | #ifdef ZLIB_SHARED | ||
| 189 | if (!zlib_loaded) | ||
| 190 | { | ||
| 191 | #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) | ||
| 192 | zlib_dso = DSO_load(NULL, "ZLIB", NULL, 0); | ||
| 193 | #else | ||
| 194 | zlib_dso = DSO_load(NULL, "z", NULL, 0); | ||
| 195 | #endif | ||
| 196 | if (zlib_dso != NULL) | ||
| 197 | { | ||
| 198 | p_compress | ||
| 199 | = (compress_ft) DSO_bind_func(zlib_dso, | ||
| 200 | "compress"); | ||
| 201 | p_inflateEnd | ||
| 202 | = (inflateEnd_ft) DSO_bind_func(zlib_dso, | ||
| 203 | "inflateEnd"); | ||
| 204 | p_inflate | ||
| 205 | = (inflate_ft) DSO_bind_func(zlib_dso, | ||
| 206 | "inflate"); | ||
| 207 | p_inflateInit_ | ||
| 208 | = (inflateInit__ft) DSO_bind_func(zlib_dso, | ||
| 209 | "inflateInit_"); | ||
| 210 | zlib_loaded++; | ||
| 211 | meth = &zlib_method; | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | #elif defined(ZLIB) | ||
| 216 | meth = &zlib_method; | ||
| 217 | #endif | ||
| 218 | |||
| 219 | return(meth); | ||
| 220 | } | ||
| 221 | |||
| 222 | #ifdef ZLIB_SHARED | ||
| 223 | /* Stubs for each function to be dynamicly loaded */ | ||
| 224 | static int | ||
| 225 | stub_compress(Bytef *dest,uLongf *destLen,const Bytef *source, uLong sourceLen) | ||
| 226 | { | ||
| 227 | if (p_compress) | ||
| 228 | return(p_compress(dest,destLen,source,sourceLen)); | ||
| 229 | else | ||
| 230 | return(Z_MEM_ERROR); | ||
| 231 | } | ||
| 232 | |||
| 233 | static int | ||
| 234 | stub_inflateEnd(z_streamp strm) | ||
| 235 | { | ||
| 236 | if ( p_inflateEnd ) | ||
| 237 | return(p_inflateEnd(strm)); | ||
| 238 | else | ||
| 239 | return(Z_MEM_ERROR); | ||
| 240 | } | ||
| 241 | |||
| 242 | static int | ||
| 243 | stub_inflate(z_streamp strm, int flush) | ||
| 244 | { | ||
| 245 | if ( p_inflate ) | ||
| 246 | return(p_inflate(strm,flush)); | ||
| 247 | else | ||
| 248 | return(Z_MEM_ERROR); | ||
| 249 | } | ||
| 250 | |||
| 251 | static int | ||
| 252 | stub_inflateInit_(z_streamp strm, const char * version, int stream_size) | ||
| 253 | { | ||
| 254 | if ( p_inflateInit_ ) | ||
| 255 | return(p_inflateInit_(strm,version,stream_size)); | ||
| 256 | else | ||
| 257 | return(Z_MEM_ERROR); | ||
| 132 | } | 258 | } |
| 133 | 259 | ||
| 260 | #endif /* ZLIB_SHARED */ | ||
diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h index 93bd9c34c8..ab48b78ae9 100644 --- a/src/lib/libcrypto/comp/comp.h +++ b/src/lib/libcrypto/comp/comp.h | |||
| @@ -2,12 +2,12 @@ | |||
| 2 | #ifndef HEADER_COMP_H | 2 | #ifndef HEADER_COMP_H |
| 3 | #define HEADER_COMP_H | 3 | #define HEADER_COMP_H |
| 4 | 4 | ||
| 5 | #include <openssl/crypto.h> | ||
| 6 | |||
| 5 | #ifdef __cplusplus | 7 | #ifdef __cplusplus |
| 6 | extern "C" { | 8 | extern "C" { |
| 7 | #endif | 9 | #endif |
| 8 | 10 | ||
| 9 | #include <openssl/crypto.h> | ||
| 10 | |||
| 11 | typedef struct comp_method_st | 11 | typedef struct comp_method_st |
| 12 | { | 12 | { |
| 13 | int type; /* NID for compression library */ | 13 | int type; /* NID for compression library */ |
| @@ -17,6 +17,7 @@ typedef struct comp_method_st | |||
| 17 | int (*compress)(); | 17 | int (*compress)(); |
| 18 | int (*expand)(); | 18 | int (*expand)(); |
| 19 | long (*ctrl)(); | 19 | long (*ctrl)(); |
| 20 | long (*callback_ctrl)(); | ||
| 20 | } COMP_METHOD; | 21 | } COMP_METHOD; |
| 21 | 22 | ||
| 22 | typedef struct comp_ctx_st | 23 | typedef struct comp_ctx_st |
| @@ -38,14 +39,13 @@ int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | |||
| 38 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | 39 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, |
| 39 | unsigned char *in, int ilen); | 40 | unsigned char *in, int ilen); |
| 40 | COMP_METHOD *COMP_rle(void ); | 41 | COMP_METHOD *COMP_rle(void ); |
| 41 | #ifdef ZLIB | ||
| 42 | COMP_METHOD *COMP_zlib(void ); | 42 | COMP_METHOD *COMP_zlib(void ); |
| 43 | #endif | ||
| 44 | 43 | ||
| 45 | /* BEGIN ERROR CODES */ | 44 | /* BEGIN ERROR CODES */ |
| 46 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 45 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| 47 | * made after this point may be overwritten when the script is next run. | 46 | * made after this point may be overwritten when the script is next run. |
| 48 | */ | 47 | */ |
| 48 | void ERR_load_COMP_strings(void); | ||
| 49 | 49 | ||
| 50 | /* Error codes for the COMP functions. */ | 50 | /* Error codes for the COMP functions. */ |
| 51 | 51 | ||
| @@ -57,4 +57,3 @@ COMP_METHOD *COMP_zlib(void ); | |||
| 57 | } | 57 | } |
| 58 | #endif | 58 | #endif |
| 59 | #endif | 59 | #endif |
| 60 | |||
diff --git a/src/lib/libcrypto/comp/comp_err.c b/src/lib/libcrypto/comp/comp_err.c index 77a3f7070c..1652b8c2c4 100644 --- a/src/lib/libcrypto/comp/comp_err.c +++ b/src/lib/libcrypto/comp/comp_err.c | |||
| @@ -54,7 +54,8 @@ | |||
| 54 | */ | 54 | */ |
| 55 | 55 | ||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes |
| 57 | * made to it will be overwritten when the script next updates this file. | 57 | * made to it will be overwritten when the script next updates this file, |
| 58 | * only reason strings will be preserved. | ||
| 58 | */ | 59 | */ |
| 59 | 60 | ||
| 60 | #include <stdio.h> | 61 | #include <stdio.h> |
| @@ -62,7 +63,7 @@ | |||
| 62 | #include <openssl/comp.h> | 63 | #include <openssl/comp.h> |
| 63 | 64 | ||
| 64 | /* BEGIN ERROR CODES */ | 65 | /* BEGIN ERROR CODES */ |
| 65 | #ifndef NO_ERR | 66 | #ifndef OPENSSL_NO_ERR |
| 66 | static ERR_STRING_DATA COMP_str_functs[]= | 67 | static ERR_STRING_DATA COMP_str_functs[]= |
| 67 | { | 68 | { |
| 68 | {0,NULL} | 69 | {0,NULL} |
| @@ -82,7 +83,7 @@ void ERR_load_COMP_strings(void) | |||
| 82 | if (init) | 83 | if (init) |
| 83 | { | 84 | { |
| 84 | init=0; | 85 | init=0; |
| 85 | #ifndef NO_ERR | 86 | #ifndef OPENSSL_NO_ERR |
| 86 | ERR_load_strings(ERR_LIB_COMP,COMP_str_functs); | 87 | ERR_load_strings(ERR_LIB_COMP,COMP_str_functs); |
| 87 | ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons); | 88 | ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons); |
| 88 | #endif | 89 | #endif |
diff --git a/src/lib/libcrypto/comp/comp_lib.c b/src/lib/libcrypto/comp/comp_lib.c index a67ef23bc0..beb98ce8cc 100644 --- a/src/lib/libcrypto/comp/comp_lib.c +++ b/src/lib/libcrypto/comp/comp_lib.c | |||
| @@ -8,7 +8,7 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) | |||
| 8 | { | 8 | { |
| 9 | COMP_CTX *ret; | 9 | COMP_CTX *ret; |
| 10 | 10 | ||
| 11 | if ((ret=(COMP_CTX *)Malloc(sizeof(COMP_CTX))) == NULL) | 11 | if ((ret=(COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) |
| 12 | { | 12 | { |
| 13 | /* ZZZZZZZZZZZZZZZZ */ | 13 | /* ZZZZZZZZZZZZZZZZ */ |
| 14 | return(NULL); | 14 | return(NULL); |
| @@ -17,7 +17,7 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) | |||
| 17 | ret->meth=meth; | 17 | ret->meth=meth; |
| 18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) | 18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) |
| 19 | { | 19 | { |
| 20 | Free(ret); | 20 | OPENSSL_free(ret); |
| 21 | ret=NULL; | 21 | ret=NULL; |
| 22 | } | 22 | } |
| 23 | #if 0 | 23 | #if 0 |
| @@ -37,7 +37,7 @@ void COMP_CTX_free(COMP_CTX *ctx) | |||
| 37 | if (ctx->meth->finish != NULL) | 37 | if (ctx->meth->finish != NULL) |
| 38 | ctx->meth->finish(ctx); | 38 | ctx->meth->finish(ctx); |
| 39 | 39 | ||
| 40 | Free(ctx); | 40 | OPENSSL_free(ctx); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | 43 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, |
