diff options
author | tedu <> | 2014-11-03 16:58:28 +0000 |
---|---|---|
committer | tedu <> | 2014-11-03 16:58:28 +0000 |
commit | c393da8a793368840f1101c4aca7d65629881539 (patch) | |
tree | 82f33c5a8e89b7c1efe3edba9f73e31fd82c52c3 | |
parent | a3eca90dbf58e4b053bf7a401300f044cfdc2256 (diff) | |
download | openbsd-c393da8a793368840f1101c4aca7d65629881539.tar.gz openbsd-c393da8a793368840f1101c4aca7d65629881539.tar.bz2 openbsd-c393da8a793368840f1101c4aca7d65629881539.zip |
minor cleanup of zlib code. DSO is gone. ok jsing.
-rw-r--r-- | src/lib/libcrypto/comp/c_rle.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/comp/c_zlib.c | 201 | ||||
-rw-r--r-- | src/lib/libcrypto/comp/comp.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/comp/comp_err.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/comp/comp_lib.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/comp/c_rle.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/comp/c_zlib.c | 201 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/comp/comp.h | 6 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/comp/comp_err.c | 7 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/comp/comp_lib.c | 5 |
10 files changed, 14 insertions, 434 deletions
diff --git a/src/lib/libcrypto/comp/c_rle.c b/src/lib/libcrypto/comp/c_rle.c index 214efe01b2..7004c35029 100644 --- a/src/lib/libcrypto/comp/c_rle.c +++ b/src/lib/libcrypto/comp/c_rle.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: c_rle.c,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: c_rle.c,v 1.8 2014/11/03 16:58:28 tedu Exp $ */ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
@@ -27,10 +27,8 @@ static int | |||
27 | rle_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, | 27 | rle_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, |
28 | unsigned char *in, unsigned int ilen) | 28 | unsigned char *in, unsigned int ilen) |
29 | { | 29 | { |
30 | /* int i; */ | ||
31 | 30 | ||
32 | if (ilen == 0 || olen < (ilen - 1)) { | 31 | if (ilen == 0 || olen < (ilen - 1)) { |
33 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
34 | return (-1); | 32 | return (-1); |
35 | } | 33 | } |
36 | 34 | ||
@@ -46,7 +44,6 @@ rle_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, | |||
46 | int i; | 44 | int i; |
47 | 45 | ||
48 | if (olen < (ilen - 1)) { | 46 | if (olen < (ilen - 1)) { |
49 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
50 | return (-1); | 47 | return (-1); |
51 | } | 48 | } |
52 | 49 | ||
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c index 11b95fb799..4951ade810 100644 --- a/src/lib/libcrypto/comp/c_zlib.c +++ b/src/lib/libcrypto/comp/c_zlib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: c_zlib.c,v 1.16 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: c_zlib.c,v 1.17 2014/11/03 16:58:28 tedu Exp $ */ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
@@ -13,9 +13,7 @@ static COMP_METHOD zlib_method_nozlib = { | |||
13 | .name = "(undef)" | 13 | .name = "(undef)" |
14 | }; | 14 | }; |
15 | 15 | ||
16 | #ifndef ZLIB | 16 | #ifdef ZLIB |
17 | #undef ZLIB_SHARED | ||
18 | #else | ||
19 | 17 | ||
20 | #include <zlib.h> | 18 | #include <zlib.h> |
21 | 19 | ||
@@ -40,23 +38,6 @@ zlib_zfree(void* opaque, void* address) | |||
40 | free(address); | 38 | free(address); |
41 | } | 39 | } |
42 | 40 | ||
43 | #if 0 | ||
44 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
45 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
46 | static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
47 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
48 | |||
49 | static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, | ||
50 | uLong sourceLen); | ||
51 | |||
52 | static COMP_METHOD zlib_stateless_method = { | ||
53 | .type = NID_zlib_compression, | ||
54 | .name = LN_zlib_compression, | ||
55 | .compress = zlib_compress_block, | ||
56 | .expand = zlib_expand_block | ||
57 | }; | ||
58 | #endif | ||
59 | |||
60 | static COMP_METHOD zlib_stateful_method = { | 41 | static COMP_METHOD zlib_stateful_method = { |
61 | .type = NID_zlib_compression, | 42 | .type = NID_zlib_compression, |
62 | .name = LN_zlib_compression, | 43 | .name = LN_zlib_compression, |
@@ -66,43 +47,6 @@ static COMP_METHOD zlib_stateful_method = { | |||
66 | .expand = zlib_stateful_expand_block | 47 | .expand = zlib_stateful_expand_block |
67 | }; | 48 | }; |
68 | 49 | ||
69 | #ifdef ZLIB_SHARED | ||
70 | #include <openssl/dso.h> | ||
71 | |||
72 | /* Function pointers */ | ||
73 | typedef int (*compress_ft)(Bytef *dest, uLongf *destLen, const Bytef *source, | ||
74 | uLong sourceLen); | ||
75 | typedef int (*inflateEnd_ft)(z_streamp strm); | ||
76 | typedef int (*inflate_ft)(z_streamp strm, int flush); | ||
77 | typedef int (*inflateInit__ft)(z_streamp strm, const char * version, | ||
78 | int stream_size); | ||
79 | typedef int (*deflateEnd_ft)(z_streamp strm); | ||
80 | typedef int (*deflate_ft)(z_streamp strm, int flush); | ||
81 | typedef int (*deflateInit__ft)(z_streamp strm, int level, const char * version, | ||
82 | int stream_size); | ||
83 | typedef const char * (*zError__ft)(int err); | ||
84 | static compress_ft p_compress = NULL; | ||
85 | static inflateEnd_ft p_inflateEnd = NULL; | ||
86 | static inflate_ft p_inflate = NULL; | ||
87 | static inflateInit__ft p_inflateInit_ = NULL; | ||
88 | static deflateEnd_ft p_deflateEnd = NULL; | ||
89 | static deflate_ft p_deflate = NULL; | ||
90 | static deflateInit__ft p_deflateInit_ = NULL; | ||
91 | static zError__ft p_zError = NULL; | ||
92 | |||
93 | static int zlib_loaded = 0; /* only attempt to init func pts once */ | ||
94 | static DSO *zlib_dso = NULL; | ||
95 | |||
96 | #define compress p_compress | ||
97 | #define inflateEnd p_inflateEnd | ||
98 | #define inflate p_inflate | ||
99 | #define inflateInit_ p_inflateInit_ | ||
100 | #define deflateEnd p_deflateEnd | ||
101 | #define deflate p_deflate | ||
102 | #define deflateInit_ p_deflateInit_ | ||
103 | #define zError p_zError | ||
104 | #endif /* ZLIB_SHARED */ | ||
105 | |||
106 | struct zlib_state { | 50 | struct zlib_state { |
107 | z_stream istream; | 51 | z_stream istream; |
108 | z_stream ostream; | 52 | z_stream ostream; |
@@ -225,102 +169,6 @@ zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, | |||
225 | return olen - state->istream.avail_out; | 169 | return olen - state->istream.avail_out; |
226 | } | 170 | } |
227 | 171 | ||
228 | #if 0 | ||
229 | static int | ||
230 | zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
231 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
232 | { | ||
233 | unsigned long l; | ||
234 | int i; | ||
235 | int clear = 1; | ||
236 | |||
237 | if (ilen > 128) { | ||
238 | out[0] = 1; | ||
239 | l = olen - 1; | ||
240 | i = compress(&(out[1]), &l, in, (unsigned long)ilen); | ||
241 | if (i != Z_OK) | ||
242 | return (-1); | ||
243 | if (ilen > l) { | ||
244 | clear = 0; | ||
245 | l++; | ||
246 | } | ||
247 | } | ||
248 | if (clear) { | ||
249 | out[0] = 0; | ||
250 | memcpy(&(out[1]), in, ilen); | ||
251 | l = ilen + 1; | ||
252 | } | ||
253 | |||
254 | #ifdef DEBUG_ZLIB | ||
255 | fprintf(stderr, "compress(%4d)->%4d %s\n", | ||
256 | ilen,(int)l, (clear)?"clear":"zlib"); | ||
257 | #endif | ||
258 | |||
259 | return ((int)l); | ||
260 | } | ||
261 | |||
262 | static int | ||
263 | zlib_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, | ||
264 | unsigned char *in, unsigned int ilen) | ||
265 | { | ||
266 | unsigned long l; | ||
267 | int i; | ||
268 | |||
269 | if (in[0]) { | ||
270 | l = olen; | ||
271 | i = zz_uncompress(out, &l, &(in[1]), (unsigned long)ilen - 1); | ||
272 | if (i != Z_OK) | ||
273 | return (-1); | ||
274 | } else { | ||
275 | memcpy(out, &(in[1]), ilen - 1); | ||
276 | l = ilen - 1; | ||
277 | } | ||
278 | |||
279 | #ifdef DEBUG_ZLIB | ||
280 | fprintf(stderr, "expand (%4d)->%4d %s\n", | ||
281 | ilen,(int)l, in[0]?"zlib":"clear"); | ||
282 | #endif | ||
283 | |||
284 | return ((int)l); | ||
285 | } | ||
286 | |||
287 | static int | ||
288 | zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, | ||
289 | uLong sourceLen) | ||
290 | { | ||
291 | z_stream stream; | ||
292 | int err; | ||
293 | |||
294 | stream.next_in = (Bytef*)source; | ||
295 | stream.avail_in = (uInt)sourceLen; | ||
296 | /* Check for source > 64K on 16-bit machine: */ | ||
297 | if ((uLong)stream.avail_in != sourceLen) | ||
298 | return Z_BUF_ERROR; | ||
299 | |||
300 | stream.next_out = dest; | ||
301 | stream.avail_out = (uInt)*destLen; | ||
302 | if ((uLong)stream.avail_out != *destLen) | ||
303 | return Z_BUF_ERROR; | ||
304 | |||
305 | stream.zalloc = (alloc_func)0; | ||
306 | stream.zfree = (free_func)0; | ||
307 | |||
308 | err = inflateInit_(&stream, ZLIB_VERSION, sizeof(z_stream)); | ||
309 | if (err != Z_OK) | ||
310 | return err; | ||
311 | |||
312 | err = inflate(&stream, Z_FINISH); | ||
313 | if (err != Z_STREAM_END) { | ||
314 | inflateEnd(&stream); | ||
315 | return err; | ||
316 | } | ||
317 | *destLen = stream.total_out; | ||
318 | |||
319 | err = inflateEnd(&stream); | ||
320 | return err; | ||
321 | } | ||
322 | #endif | ||
323 | |||
324 | #endif | 172 | #endif |
325 | 173 | ||
326 | COMP_METHOD * | 174 | COMP_METHOD * |
@@ -328,39 +176,7 @@ COMP_zlib(void) | |||
328 | { | 176 | { |
329 | COMP_METHOD *meth = &zlib_method_nozlib; | 177 | COMP_METHOD *meth = &zlib_method_nozlib; |
330 | 178 | ||
331 | #ifdef ZLIB_SHARED | 179 | #ifdef ZLIB |
332 | if (!zlib_loaded) { | ||
333 | zlib_dso = DSO_load(NULL, "z", NULL, 0); | ||
334 | if (zlib_dso != NULL) { | ||
335 | p_compress = (compress_ft)DSO_bind_func( | ||
336 | zlib_dso, "compress"); | ||
337 | p_inflateEnd = (inflateEnd_ft)DSO_bind_func( | ||
338 | zlib_dso, "inflateEnd"); | ||
339 | p_inflate = (inflate_ft)DSO_bind_func( | ||
340 | zlib_dso, "inflate"); | ||
341 | p_inflateInit_ = (inflateInit__ft)DSO_bind_func( | ||
342 | zlib_dso, "inflateInit_"); | ||
343 | p_deflateEnd = (deflateEnd_ft)DSO_bind_func( | ||
344 | zlib_dso, "deflateEnd"); | ||
345 | p_deflate = (deflate_ft)DSO_bind_func( | ||
346 | zlib_dso, "deflate"); | ||
347 | p_deflateInit_ = (deflateInit__ft)DSO_bind_func( | ||
348 | zlib_dso, "deflateInit_"); | ||
349 | p_zError = (zError__ft)DSO_bind_func( | ||
350 | zlib_dso, "zError"); | ||
351 | |||
352 | if (p_compress && p_inflateEnd && p_inflate && | ||
353 | p_inflateInit_ && p_deflateEnd && p_deflate && | ||
354 | p_deflateInit_ && p_zError) | ||
355 | zlib_loaded++; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | #endif | ||
360 | #ifdef ZLIB_SHARED | ||
361 | if (zlib_loaded) | ||
362 | #endif | ||
363 | #if defined(ZLIB) || defined(ZLIB_SHARED) | ||
364 | { | 180 | { |
365 | /* init zlib_stateful_ex_idx here so that in a multi-process | 181 | /* init zlib_stateful_ex_idx here so that in a multi-process |
366 | * application it's enough to intialize openssl before forking | 182 | * application it's enough to intialize openssl before forking |
@@ -388,10 +204,6 @@ err: | |||
388 | void | 204 | void |
389 | COMP_zlib_cleanup(void) | 205 | COMP_zlib_cleanup(void) |
390 | { | 206 | { |
391 | #ifdef ZLIB_SHARED | ||
392 | if (zlib_dso) | ||
393 | DSO_free(zlib_dso); | ||
394 | #endif | ||
395 | } | 207 | } |
396 | 208 | ||
397 | #ifdef ZLIB | 209 | #ifdef ZLIB |
@@ -443,13 +255,6 @@ bio_zlib_new(BIO *bi) | |||
443 | { | 255 | { |
444 | BIO_ZLIB_CTX *ctx; | 256 | BIO_ZLIB_CTX *ctx; |
445 | 257 | ||
446 | #ifdef ZLIB_SHARED | ||
447 | (void)COMP_zlib(); | ||
448 | if (!zlib_loaded) { | ||
449 | COMPerr(COMP_F_BIO_ZLIB_NEW, COMP_R_ZLIB_NOT_SUPPORTED); | ||
450 | return 0; | ||
451 | } | ||
452 | #endif | ||
453 | ctx = malloc(sizeof(BIO_ZLIB_CTX)); | 258 | ctx = malloc(sizeof(BIO_ZLIB_CTX)); |
454 | if (!ctx) { | 259 | if (!ctx) { |
455 | COMPerr(COMP_F_BIO_ZLIB_NEW, ERR_R_MALLOC_FAILURE); | 260 | COMPerr(COMP_F_BIO_ZLIB_NEW, ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h index d1e252988b..fe7397f8ea 100644 --- a/src/lib/libcrypto/comp/comp.h +++ b/src/lib/libcrypto/comp/comp.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: comp.h,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: comp.h,v 1.8 2014/11/03 16:58:28 tedu Exp $ */ |
2 | 2 | ||
3 | #ifndef HEADER_COMP_H | 3 | #ifndef HEADER_COMP_H |
4 | #define HEADER_COMP_H | 4 | #define HEADER_COMP_H |
@@ -52,10 +52,6 @@ BIO_METHOD *BIO_f_zlib(void); | |||
52 | #endif | 52 | #endif |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | /* BEGIN ERROR CODES */ | ||
56 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
57 | * made after this point may be overwritten when the script is next run. | ||
58 | */ | ||
59 | void ERR_load_COMP_strings(void); | 55 | void ERR_load_COMP_strings(void); |
60 | 56 | ||
61 | /* Error codes for the COMP functions. */ | 57 | /* Error codes for the COMP functions. */ |
diff --git a/src/lib/libcrypto/comp/comp_err.c b/src/lib/libcrypto/comp/comp_err.c index 1174df430f..3f796d4069 100644 --- a/src/lib/libcrypto/comp/comp_err.c +++ b/src/lib/libcrypto/comp/comp_err.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: comp_err.c,v 1.8 2014/07/10 22:45:56 jsing Exp $ */ | 1 | /* $OpenBSD: comp_err.c,v 1.9 2014/11/03 16:58:28 tedu Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -53,11 +53,6 @@ | |||
53 | * | 53 | * |
54 | */ | 54 | */ |
55 | 55 | ||
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, | ||
58 | * only reason strings will be preserved. | ||
59 | */ | ||
60 | |||
61 | #include <stdio.h> | 56 | #include <stdio.h> |
62 | 57 | ||
63 | #include <openssl/opensslconf.h> | 58 | #include <openssl/opensslconf.h> |
diff --git a/src/lib/libcrypto/comp/comp_lib.c b/src/lib/libcrypto/comp/comp_lib.c index 78a01a698c..dde238ef72 100644 --- a/src/lib/libcrypto/comp/comp_lib.c +++ b/src/lib/libcrypto/comp/comp_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: comp_lib.c,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: comp_lib.c,v 1.8 2014/11/03 16:58:28 tedu Exp $ */ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
@@ -11,7 +11,6 @@ COMP_CTX_new(COMP_METHOD *meth) | |||
11 | COMP_CTX *ret; | 11 | COMP_CTX *ret; |
12 | 12 | ||
13 | if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) { | 13 | if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) { |
14 | /* ZZZZZZZZZZZZZZZZ */ | ||
15 | return (NULL); | 14 | return (NULL); |
16 | } | 15 | } |
17 | ret->meth = meth; | 16 | ret->meth = meth; |
@@ -41,7 +40,6 @@ COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | |||
41 | int ret; | 40 | int ret; |
42 | 41 | ||
43 | if (ctx->meth->compress == NULL) { | 42 | if (ctx->meth->compress == NULL) { |
44 | /* ZZZZZZZZZZZZZZZZZ */ | ||
45 | return (-1); | 43 | return (-1); |
46 | } | 44 | } |
47 | ret = ctx->meth->compress(ctx, out, olen, in, ilen); | 45 | ret = ctx->meth->compress(ctx, out, olen, in, ilen); |
@@ -59,7 +57,6 @@ COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | |||
59 | int ret; | 57 | int ret; |
60 | 58 | ||
61 | if (ctx->meth->expand == NULL) { | 59 | if (ctx->meth->expand == NULL) { |
62 | /* ZZZZZZZZZZZZZZZZZ */ | ||
63 | return (-1); | 60 | return (-1); |
64 | } | 61 | } |
65 | ret = ctx->meth->expand(ctx, out, olen, in, ilen); | 62 | ret = ctx->meth->expand(ctx, out, olen, in, ilen); |
diff --git a/src/lib/libssl/src/crypto/comp/c_rle.c b/src/lib/libssl/src/crypto/comp/c_rle.c index 214efe01b2..7004c35029 100644 --- a/src/lib/libssl/src/crypto/comp/c_rle.c +++ b/src/lib/libssl/src/crypto/comp/c_rle.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: c_rle.c,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: c_rle.c,v 1.8 2014/11/03 16:58:28 tedu Exp $ */ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
@@ -27,10 +27,8 @@ static int | |||
27 | rle_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, | 27 | rle_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, |
28 | unsigned char *in, unsigned int ilen) | 28 | unsigned char *in, unsigned int ilen) |
29 | { | 29 | { |
30 | /* int i; */ | ||
31 | 30 | ||
32 | if (ilen == 0 || olen < (ilen - 1)) { | 31 | if (ilen == 0 || olen < (ilen - 1)) { |
33 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
34 | return (-1); | 32 | return (-1); |
35 | } | 33 | } |
36 | 34 | ||
@@ -46,7 +44,6 @@ rle_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, | |||
46 | int i; | 44 | int i; |
47 | 45 | ||
48 | if (olen < (ilen - 1)) { | 46 | if (olen < (ilen - 1)) { |
49 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
50 | return (-1); | 47 | return (-1); |
51 | } | 48 | } |
52 | 49 | ||
diff --git a/src/lib/libssl/src/crypto/comp/c_zlib.c b/src/lib/libssl/src/crypto/comp/c_zlib.c index 11b95fb799..4951ade810 100644 --- a/src/lib/libssl/src/crypto/comp/c_zlib.c +++ b/src/lib/libssl/src/crypto/comp/c_zlib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: c_zlib.c,v 1.16 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: c_zlib.c,v 1.17 2014/11/03 16:58:28 tedu Exp $ */ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
@@ -13,9 +13,7 @@ static COMP_METHOD zlib_method_nozlib = { | |||
13 | .name = "(undef)" | 13 | .name = "(undef)" |
14 | }; | 14 | }; |
15 | 15 | ||
16 | #ifndef ZLIB | 16 | #ifdef ZLIB |
17 | #undef ZLIB_SHARED | ||
18 | #else | ||
19 | 17 | ||
20 | #include <zlib.h> | 18 | #include <zlib.h> |
21 | 19 | ||
@@ -40,23 +38,6 @@ zlib_zfree(void* opaque, void* address) | |||
40 | free(address); | 38 | free(address); |
41 | } | 39 | } |
42 | 40 | ||
43 | #if 0 | ||
44 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
45 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
46 | static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
47 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
48 | |||
49 | static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, | ||
50 | uLong sourceLen); | ||
51 | |||
52 | static COMP_METHOD zlib_stateless_method = { | ||
53 | .type = NID_zlib_compression, | ||
54 | .name = LN_zlib_compression, | ||
55 | .compress = zlib_compress_block, | ||
56 | .expand = zlib_expand_block | ||
57 | }; | ||
58 | #endif | ||
59 | |||
60 | static COMP_METHOD zlib_stateful_method = { | 41 | static COMP_METHOD zlib_stateful_method = { |
61 | .type = NID_zlib_compression, | 42 | .type = NID_zlib_compression, |
62 | .name = LN_zlib_compression, | 43 | .name = LN_zlib_compression, |
@@ -66,43 +47,6 @@ static COMP_METHOD zlib_stateful_method = { | |||
66 | .expand = zlib_stateful_expand_block | 47 | .expand = zlib_stateful_expand_block |
67 | }; | 48 | }; |
68 | 49 | ||
69 | #ifdef ZLIB_SHARED | ||
70 | #include <openssl/dso.h> | ||
71 | |||
72 | /* Function pointers */ | ||
73 | typedef int (*compress_ft)(Bytef *dest, uLongf *destLen, const Bytef *source, | ||
74 | uLong sourceLen); | ||
75 | typedef int (*inflateEnd_ft)(z_streamp strm); | ||
76 | typedef int (*inflate_ft)(z_streamp strm, int flush); | ||
77 | typedef int (*inflateInit__ft)(z_streamp strm, const char * version, | ||
78 | int stream_size); | ||
79 | typedef int (*deflateEnd_ft)(z_streamp strm); | ||
80 | typedef int (*deflate_ft)(z_streamp strm, int flush); | ||
81 | typedef int (*deflateInit__ft)(z_streamp strm, int level, const char * version, | ||
82 | int stream_size); | ||
83 | typedef const char * (*zError__ft)(int err); | ||
84 | static compress_ft p_compress = NULL; | ||
85 | static inflateEnd_ft p_inflateEnd = NULL; | ||
86 | static inflate_ft p_inflate = NULL; | ||
87 | static inflateInit__ft p_inflateInit_ = NULL; | ||
88 | static deflateEnd_ft p_deflateEnd = NULL; | ||
89 | static deflate_ft p_deflate = NULL; | ||
90 | static deflateInit__ft p_deflateInit_ = NULL; | ||
91 | static zError__ft p_zError = NULL; | ||
92 | |||
93 | static int zlib_loaded = 0; /* only attempt to init func pts once */ | ||
94 | static DSO *zlib_dso = NULL; | ||
95 | |||
96 | #define compress p_compress | ||
97 | #define inflateEnd p_inflateEnd | ||
98 | #define inflate p_inflate | ||
99 | #define inflateInit_ p_inflateInit_ | ||
100 | #define deflateEnd p_deflateEnd | ||
101 | #define deflate p_deflate | ||
102 | #define deflateInit_ p_deflateInit_ | ||
103 | #define zError p_zError | ||
104 | #endif /* ZLIB_SHARED */ | ||
105 | |||
106 | struct zlib_state { | 50 | struct zlib_state { |
107 | z_stream istream; | 51 | z_stream istream; |
108 | z_stream ostream; | 52 | z_stream ostream; |
@@ -225,102 +169,6 @@ zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, | |||
225 | return olen - state->istream.avail_out; | 169 | return olen - state->istream.avail_out; |
226 | } | 170 | } |
227 | 171 | ||
228 | #if 0 | ||
229 | static int | ||
230 | zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
231 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
232 | { | ||
233 | unsigned long l; | ||
234 | int i; | ||
235 | int clear = 1; | ||
236 | |||
237 | if (ilen > 128) { | ||
238 | out[0] = 1; | ||
239 | l = olen - 1; | ||
240 | i = compress(&(out[1]), &l, in, (unsigned long)ilen); | ||
241 | if (i != Z_OK) | ||
242 | return (-1); | ||
243 | if (ilen > l) { | ||
244 | clear = 0; | ||
245 | l++; | ||
246 | } | ||
247 | } | ||
248 | if (clear) { | ||
249 | out[0] = 0; | ||
250 | memcpy(&(out[1]), in, ilen); | ||
251 | l = ilen + 1; | ||
252 | } | ||
253 | |||
254 | #ifdef DEBUG_ZLIB | ||
255 | fprintf(stderr, "compress(%4d)->%4d %s\n", | ||
256 | ilen,(int)l, (clear)?"clear":"zlib"); | ||
257 | #endif | ||
258 | |||
259 | return ((int)l); | ||
260 | } | ||
261 | |||
262 | static int | ||
263 | zlib_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, | ||
264 | unsigned char *in, unsigned int ilen) | ||
265 | { | ||
266 | unsigned long l; | ||
267 | int i; | ||
268 | |||
269 | if (in[0]) { | ||
270 | l = olen; | ||
271 | i = zz_uncompress(out, &l, &(in[1]), (unsigned long)ilen - 1); | ||
272 | if (i != Z_OK) | ||
273 | return (-1); | ||
274 | } else { | ||
275 | memcpy(out, &(in[1]), ilen - 1); | ||
276 | l = ilen - 1; | ||
277 | } | ||
278 | |||
279 | #ifdef DEBUG_ZLIB | ||
280 | fprintf(stderr, "expand (%4d)->%4d %s\n", | ||
281 | ilen,(int)l, in[0]?"zlib":"clear"); | ||
282 | #endif | ||
283 | |||
284 | return ((int)l); | ||
285 | } | ||
286 | |||
287 | static int | ||
288 | zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, | ||
289 | uLong sourceLen) | ||
290 | { | ||
291 | z_stream stream; | ||
292 | int err; | ||
293 | |||
294 | stream.next_in = (Bytef*)source; | ||
295 | stream.avail_in = (uInt)sourceLen; | ||
296 | /* Check for source > 64K on 16-bit machine: */ | ||
297 | if ((uLong)stream.avail_in != sourceLen) | ||
298 | return Z_BUF_ERROR; | ||
299 | |||
300 | stream.next_out = dest; | ||
301 | stream.avail_out = (uInt)*destLen; | ||
302 | if ((uLong)stream.avail_out != *destLen) | ||
303 | return Z_BUF_ERROR; | ||
304 | |||
305 | stream.zalloc = (alloc_func)0; | ||
306 | stream.zfree = (free_func)0; | ||
307 | |||
308 | err = inflateInit_(&stream, ZLIB_VERSION, sizeof(z_stream)); | ||
309 | if (err != Z_OK) | ||
310 | return err; | ||
311 | |||
312 | err = inflate(&stream, Z_FINISH); | ||
313 | if (err != Z_STREAM_END) { | ||
314 | inflateEnd(&stream); | ||
315 | return err; | ||
316 | } | ||
317 | *destLen = stream.total_out; | ||
318 | |||
319 | err = inflateEnd(&stream); | ||
320 | return err; | ||
321 | } | ||
322 | #endif | ||
323 | |||
324 | #endif | 172 | #endif |
325 | 173 | ||
326 | COMP_METHOD * | 174 | COMP_METHOD * |
@@ -328,39 +176,7 @@ COMP_zlib(void) | |||
328 | { | 176 | { |
329 | COMP_METHOD *meth = &zlib_method_nozlib; | 177 | COMP_METHOD *meth = &zlib_method_nozlib; |
330 | 178 | ||
331 | #ifdef ZLIB_SHARED | 179 | #ifdef ZLIB |
332 | if (!zlib_loaded) { | ||
333 | zlib_dso = DSO_load(NULL, "z", NULL, 0); | ||
334 | if (zlib_dso != NULL) { | ||
335 | p_compress = (compress_ft)DSO_bind_func( | ||
336 | zlib_dso, "compress"); | ||
337 | p_inflateEnd = (inflateEnd_ft)DSO_bind_func( | ||
338 | zlib_dso, "inflateEnd"); | ||
339 | p_inflate = (inflate_ft)DSO_bind_func( | ||
340 | zlib_dso, "inflate"); | ||
341 | p_inflateInit_ = (inflateInit__ft)DSO_bind_func( | ||
342 | zlib_dso, "inflateInit_"); | ||
343 | p_deflateEnd = (deflateEnd_ft)DSO_bind_func( | ||
344 | zlib_dso, "deflateEnd"); | ||
345 | p_deflate = (deflate_ft)DSO_bind_func( | ||
346 | zlib_dso, "deflate"); | ||
347 | p_deflateInit_ = (deflateInit__ft)DSO_bind_func( | ||
348 | zlib_dso, "deflateInit_"); | ||
349 | p_zError = (zError__ft)DSO_bind_func( | ||
350 | zlib_dso, "zError"); | ||
351 | |||
352 | if (p_compress && p_inflateEnd && p_inflate && | ||
353 | p_inflateInit_ && p_deflateEnd && p_deflate && | ||
354 | p_deflateInit_ && p_zError) | ||
355 | zlib_loaded++; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | #endif | ||
360 | #ifdef ZLIB_SHARED | ||
361 | if (zlib_loaded) | ||
362 | #endif | ||
363 | #if defined(ZLIB) || defined(ZLIB_SHARED) | ||
364 | { | 180 | { |
365 | /* init zlib_stateful_ex_idx here so that in a multi-process | 181 | /* init zlib_stateful_ex_idx here so that in a multi-process |
366 | * application it's enough to intialize openssl before forking | 182 | * application it's enough to intialize openssl before forking |
@@ -388,10 +204,6 @@ err: | |||
388 | void | 204 | void |
389 | COMP_zlib_cleanup(void) | 205 | COMP_zlib_cleanup(void) |
390 | { | 206 | { |
391 | #ifdef ZLIB_SHARED | ||
392 | if (zlib_dso) | ||
393 | DSO_free(zlib_dso); | ||
394 | #endif | ||
395 | } | 207 | } |
396 | 208 | ||
397 | #ifdef ZLIB | 209 | #ifdef ZLIB |
@@ -443,13 +255,6 @@ bio_zlib_new(BIO *bi) | |||
443 | { | 255 | { |
444 | BIO_ZLIB_CTX *ctx; | 256 | BIO_ZLIB_CTX *ctx; |
445 | 257 | ||
446 | #ifdef ZLIB_SHARED | ||
447 | (void)COMP_zlib(); | ||
448 | if (!zlib_loaded) { | ||
449 | COMPerr(COMP_F_BIO_ZLIB_NEW, COMP_R_ZLIB_NOT_SUPPORTED); | ||
450 | return 0; | ||
451 | } | ||
452 | #endif | ||
453 | ctx = malloc(sizeof(BIO_ZLIB_CTX)); | 258 | ctx = malloc(sizeof(BIO_ZLIB_CTX)); |
454 | if (!ctx) { | 259 | if (!ctx) { |
455 | COMPerr(COMP_F_BIO_ZLIB_NEW, ERR_R_MALLOC_FAILURE); | 260 | COMPerr(COMP_F_BIO_ZLIB_NEW, ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libssl/src/crypto/comp/comp.h b/src/lib/libssl/src/crypto/comp/comp.h index d1e252988b..fe7397f8ea 100644 --- a/src/lib/libssl/src/crypto/comp/comp.h +++ b/src/lib/libssl/src/crypto/comp/comp.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: comp.h,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: comp.h,v 1.8 2014/11/03 16:58:28 tedu Exp $ */ |
2 | 2 | ||
3 | #ifndef HEADER_COMP_H | 3 | #ifndef HEADER_COMP_H |
4 | #define HEADER_COMP_H | 4 | #define HEADER_COMP_H |
@@ -52,10 +52,6 @@ BIO_METHOD *BIO_f_zlib(void); | |||
52 | #endif | 52 | #endif |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | /* BEGIN ERROR CODES */ | ||
56 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
57 | * made after this point may be overwritten when the script is next run. | ||
58 | */ | ||
59 | void ERR_load_COMP_strings(void); | 55 | void ERR_load_COMP_strings(void); |
60 | 56 | ||
61 | /* Error codes for the COMP functions. */ | 57 | /* Error codes for the COMP functions. */ |
diff --git a/src/lib/libssl/src/crypto/comp/comp_err.c b/src/lib/libssl/src/crypto/comp/comp_err.c index 1174df430f..3f796d4069 100644 --- a/src/lib/libssl/src/crypto/comp/comp_err.c +++ b/src/lib/libssl/src/crypto/comp/comp_err.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: comp_err.c,v 1.8 2014/07/10 22:45:56 jsing Exp $ */ | 1 | /* $OpenBSD: comp_err.c,v 1.9 2014/11/03 16:58:28 tedu Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -53,11 +53,6 @@ | |||
53 | * | 53 | * |
54 | */ | 54 | */ |
55 | 55 | ||
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, | ||
58 | * only reason strings will be preserved. | ||
59 | */ | ||
60 | |||
61 | #include <stdio.h> | 56 | #include <stdio.h> |
62 | 57 | ||
63 | #include <openssl/opensslconf.h> | 58 | #include <openssl/opensslconf.h> |
diff --git a/src/lib/libssl/src/crypto/comp/comp_lib.c b/src/lib/libssl/src/crypto/comp/comp_lib.c index 78a01a698c..dde238ef72 100644 --- a/src/lib/libssl/src/crypto/comp/comp_lib.c +++ b/src/lib/libssl/src/crypto/comp/comp_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: comp_lib.c,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: comp_lib.c,v 1.8 2014/11/03 16:58:28 tedu Exp $ */ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
@@ -11,7 +11,6 @@ COMP_CTX_new(COMP_METHOD *meth) | |||
11 | COMP_CTX *ret; | 11 | COMP_CTX *ret; |
12 | 12 | ||
13 | if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) { | 13 | if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) { |
14 | /* ZZZZZZZZZZZZZZZZ */ | ||
15 | return (NULL); | 14 | return (NULL); |
16 | } | 15 | } |
17 | ret->meth = meth; | 16 | ret->meth = meth; |
@@ -41,7 +40,6 @@ COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | |||
41 | int ret; | 40 | int ret; |
42 | 41 | ||
43 | if (ctx->meth->compress == NULL) { | 42 | if (ctx->meth->compress == NULL) { |
44 | /* ZZZZZZZZZZZZZZZZZ */ | ||
45 | return (-1); | 43 | return (-1); |
46 | } | 44 | } |
47 | ret = ctx->meth->compress(ctx, out, olen, in, ilen); | 45 | ret = ctx->meth->compress(ctx, out, olen, in, ilen); |
@@ -59,7 +57,6 @@ COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | |||
59 | int ret; | 57 | int ret; |
60 | 58 | ||
61 | if (ctx->meth->expand == NULL) { | 59 | if (ctx->meth->expand == NULL) { |
62 | /* ZZZZZZZZZZZZZZZZZ */ | ||
63 | return (-1); | 60 | return (-1); |
64 | } | 61 | } |
65 | ret = ctx->meth->expand(ctx, out, olen, in, ilen); | 62 | ret = ctx->meth->expand(ctx, out, olen, in, ilen); |