diff options
author | jsing <> | 2015-03-27 12:29:54 +0000 |
---|---|---|
committer | jsing <> | 2015-03-27 12:29:54 +0000 |
commit | 87dfb52384d6fa9cdb7418cfc6f81f1a121e862b (patch) | |
tree | d1107e1e9c18e2392e54fb1e385c31262c4dbd2e | |
parent | ed007e156e0546eb8a587a5b57c7e0509ea52a2c (diff) | |
download | openbsd-87dfb52384d6fa9cdb7418cfc6f81f1a121e862b.tar.gz openbsd-87dfb52384d6fa9cdb7418cfc6f81f1a121e862b.tar.bz2 openbsd-87dfb52384d6fa9cdb7418cfc6f81f1a121e862b.zip |
Factor out the init_buf initialisation code, rather than duplicating it
in four different places.
ok doug@ guenther@
-rw-r--r-- | src/lib/libssl/d1_clnt.c | 26 | ||||
-rw-r--r-- | src/lib/libssl/d1_srvr.c | 18 | ||||
-rw-r--r-- | src/lib/libssl/s23_clnt.c | 23 | ||||
-rw-r--r-- | src/lib/libssl/s23_srvr.c | 20 | ||||
-rw-r--r-- | src/lib/libssl/s3_both.c | 25 | ||||
-rw-r--r-- | src/lib/libssl/s3_clnt.c | 25 | ||||
-rw-r--r-- | src/lib/libssl/s3_srvr.c | 19 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/d1_clnt.c | 26 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/d1_srvr.c | 18 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s23_clnt.c | 23 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s23_srvr.c | 20 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s3_both.c | 25 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s3_clnt.c | 25 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s3_srvr.c | 19 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/ssl_locl.h | 3 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 3 |
16 files changed, 112 insertions, 206 deletions
diff --git a/src/lib/libssl/d1_clnt.c b/src/lib/libssl/d1_clnt.c index cf25183de5..e44c8a0c94 100644 --- a/src/lib/libssl/d1_clnt.c +++ b/src/lib/libssl/d1_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_clnt.c,v 1.43 2015/02/09 10:53:28 jsing Exp $ */ | 1 | /* $OpenBSD: d1_clnt.c,v 1.44 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -176,7 +176,6 @@ dtls1_get_client_method(int ver) | |||
176 | int | 176 | int |
177 | dtls1_connect(SSL *s) | 177 | dtls1_connect(SSL *s) |
178 | { | 178 | { |
179 | BUF_MEM *buf = NULL; | ||
180 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | 179 | void (*cb)(const SSL *ssl, int type, int val) = NULL; |
181 | int ret = -1; | 180 | int ret = -1; |
182 | int new_state, state, skip = 0; | 181 | int new_state, state, skip = 0; |
@@ -223,25 +222,14 @@ dtls1_connect(SSL *s) | |||
223 | /* s->version=SSL3_VERSION; */ | 222 | /* s->version=SSL3_VERSION; */ |
224 | s->type = SSL_ST_CONNECT; | 223 | s->type = SSL_ST_CONNECT; |
225 | 224 | ||
226 | if (s->init_buf == NULL) { | 225 | if (!ssl3_setup_init_buffer(s)) { |
227 | if ((buf = BUF_MEM_new()) == NULL) { | 226 | ret = -1; |
228 | ret = -1; | 227 | goto end; |
229 | goto end; | ||
230 | } | ||
231 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
232 | ret = -1; | ||
233 | goto end; | ||
234 | } | ||
235 | s->init_buf = buf; | ||
236 | buf = NULL; | ||
237 | } | 228 | } |
238 | |||
239 | if (!ssl3_setup_buffers(s)) { | 229 | if (!ssl3_setup_buffers(s)) { |
240 | ret = -1; | 230 | ret = -1; |
241 | goto end; | 231 | goto end; |
242 | } | 232 | } |
243 | |||
244 | /* setup buffing BIO */ | ||
245 | if (!ssl_init_wbio_buffer(s, 0)) { | 233 | if (!ssl_init_wbio_buffer(s, 0)) { |
246 | ret = -1; | 234 | ret = -1; |
247 | goto end; | 235 | goto end; |
@@ -603,14 +591,12 @@ dtls1_connect(SSL *s) | |||
603 | } | 591 | } |
604 | skip = 0; | 592 | skip = 0; |
605 | } | 593 | } |
594 | |||
606 | end: | 595 | end: |
607 | s->in_handshake--; | 596 | s->in_handshake--; |
608 | |||
609 | |||
610 | if (buf != NULL) | ||
611 | BUF_MEM_free(buf); | ||
612 | if (cb != NULL) | 597 | if (cb != NULL) |
613 | cb(s, SSL_CB_CONNECT_EXIT, ret); | 598 | cb(s, SSL_CB_CONNECT_EXIT, ret); |
599 | |||
614 | return (ret); | 600 | return (ret); |
615 | } | 601 | } |
616 | 602 | ||
diff --git a/src/lib/libssl/d1_srvr.c b/src/lib/libssl/d1_srvr.c index 4e6d0da3b3..1d3779f567 100644 --- a/src/lib/libssl/d1_srvr.c +++ b/src/lib/libssl/d1_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_srvr.c,v 1.49 2015/02/09 10:53:28 jsing Exp $ */ | 1 | /* $OpenBSD: d1_srvr.c,v 1.50 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -228,20 +228,10 @@ dtls1_accept(SSL *s) | |||
228 | } | 228 | } |
229 | s->type = SSL_ST_ACCEPT; | 229 | s->type = SSL_ST_ACCEPT; |
230 | 230 | ||
231 | if (s->init_buf == NULL) { | 231 | if (!ssl3_setup_init_buffer(s)) { |
232 | BUF_MEM *buf; | 232 | ret = -1; |
233 | if ((buf = BUF_MEM_new()) == NULL) { | 233 | goto end; |
234 | ret = -1; | ||
235 | goto end; | ||
236 | } | ||
237 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
238 | BUF_MEM_free(buf); | ||
239 | ret = -1; | ||
240 | goto end; | ||
241 | } | ||
242 | s->init_buf = buf; | ||
243 | } | 234 | } |
244 | |||
245 | if (!ssl3_setup_buffers(s)) { | 235 | if (!ssl3_setup_buffers(s)) { |
246 | ret = -1; | 236 | ret = -1; |
247 | goto end; | 237 | goto end; |
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c index 4159ae0580..0ab56fa38d 100644 --- a/src/lib/libssl/s23_clnt.c +++ b/src/lib/libssl/s23_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s23_clnt.c,v 1.36 2015/02/06 08:30:23 jsing Exp $ */ | 1 | /* $OpenBSD: s23_clnt.c,v 1.37 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -176,7 +176,6 @@ ssl23_get_client_method(int ver) | |||
176 | int | 176 | int |
177 | ssl23_connect(SSL *s) | 177 | ssl23_connect(SSL *s) |
178 | { | 178 | { |
179 | BUF_MEM *buf = NULL; | ||
180 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | 179 | void (*cb)(const SSL *ssl, int type, int val) = NULL; |
181 | int ret = -1; | 180 | int ret = -1; |
182 | int new_state, state; | 181 | int new_state, state; |
@@ -214,24 +213,14 @@ ssl23_connect(SSL *s) | |||
214 | /* s->version=TLS1_VERSION; */ | 213 | /* s->version=TLS1_VERSION; */ |
215 | s->type = SSL_ST_CONNECT; | 214 | s->type = SSL_ST_CONNECT; |
216 | 215 | ||
217 | if (s->init_buf == NULL) { | 216 | if (!ssl3_setup_init_buffer(s)) { |
218 | if ((buf = BUF_MEM_new()) == NULL) { | 217 | ret = -1; |
219 | ret = -1; | 218 | goto end; |
220 | goto end; | ||
221 | } | ||
222 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
223 | ret = -1; | ||
224 | goto end; | ||
225 | } | ||
226 | s->init_buf = buf; | ||
227 | buf = NULL; | ||
228 | } | 219 | } |
229 | |||
230 | if (!ssl3_setup_buffers(s)) { | 220 | if (!ssl3_setup_buffers(s)) { |
231 | ret = -1; | 221 | ret = -1; |
232 | goto end; | 222 | goto end; |
233 | } | 223 | } |
234 | |||
235 | if (!ssl3_init_finished_mac(s)) { | 224 | if (!ssl3_init_finished_mac(s)) { |
236 | ret = -1; | 225 | ret = -1; |
237 | goto end; | 226 | goto end; |
@@ -280,12 +269,12 @@ ssl23_connect(SSL *s) | |||
280 | s->state = new_state; | 269 | s->state = new_state; |
281 | } | 270 | } |
282 | } | 271 | } |
272 | |||
283 | end: | 273 | end: |
284 | s->in_handshake--; | 274 | s->in_handshake--; |
285 | if (buf != NULL) | ||
286 | BUF_MEM_free(buf); | ||
287 | if (cb != NULL) | 275 | if (cb != NULL) |
288 | cb(s, SSL_CB_CONNECT_EXIT, ret); | 276 | cb(s, SSL_CB_CONNECT_EXIT, ret); |
277 | |||
289 | return (ret); | 278 | return (ret); |
290 | } | 279 | } |
291 | 280 | ||
diff --git a/src/lib/libssl/s23_srvr.c b/src/lib/libssl/s23_srvr.c index 9e0ee453db..99bfaf07e4 100644 --- a/src/lib/libssl/s23_srvr.c +++ b/src/lib/libssl/s23_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s23_srvr.c,v 1.38 2015/02/06 08:30:23 jsing Exp $ */ | 1 | /* $OpenBSD: s23_srvr.c,v 1.39 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -207,20 +207,10 @@ ssl23_accept(SSL *s) | |||
207 | /* s->version=SSL3_VERSION; */ | 207 | /* s->version=SSL3_VERSION; */ |
208 | s->type = SSL_ST_ACCEPT; | 208 | s->type = SSL_ST_ACCEPT; |
209 | 209 | ||
210 | if (s->init_buf == NULL) { | 210 | if (!ssl3_setup_init_buffer(s)) { |
211 | BUF_MEM *buf; | 211 | ret = -1; |
212 | if ((buf = BUF_MEM_new()) == NULL) { | 212 | goto end; |
213 | ret = -1; | ||
214 | goto end; | ||
215 | } | ||
216 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
217 | BUF_MEM_free(buf); | ||
218 | ret = -1; | ||
219 | goto end; | ||
220 | } | ||
221 | s->init_buf = buf; | ||
222 | } | 213 | } |
223 | |||
224 | if (!ssl3_init_finished_mac(s)) { | 214 | if (!ssl3_init_finished_mac(s)) { |
225 | ret = -1; | 215 | ret = -1; |
226 | goto end; | 216 | goto end; |
@@ -255,10 +245,12 @@ ssl23_accept(SSL *s) | |||
255 | s->state = new_state; | 245 | s->state = new_state; |
256 | } | 246 | } |
257 | } | 247 | } |
248 | |||
258 | end: | 249 | end: |
259 | s->in_handshake--; | 250 | s->in_handshake--; |
260 | if (cb != NULL) | 251 | if (cb != NULL) |
261 | cb(s, SSL_CB_ACCEPT_EXIT, ret); | 252 | cb(s, SSL_CB_ACCEPT_EXIT, ret); |
253 | |||
262 | return (ret); | 254 | return (ret); |
263 | } | 255 | } |
264 | 256 | ||
diff --git a/src/lib/libssl/s3_both.c b/src/lib/libssl/s3_both.c index a2ce9e9fa3..633bf5bb7b 100644 --- a/src/lib/libssl/s3_both.c +++ b/src/lib/libssl/s3_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_both.c,v 1.37 2014/12/14 21:49:29 bcook Exp $ */ | 1 | /* $OpenBSD: s3_both.c,v 1.38 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -607,6 +607,27 @@ ssl_verify_alarm_type(long type) | |||
607 | } | 607 | } |
608 | 608 | ||
609 | int | 609 | int |
610 | ssl3_setup_init_buffer(SSL *s) | ||
611 | { | ||
612 | BUF_MEM *buf = NULL; | ||
613 | |||
614 | if (s->init_buf != NULL) | ||
615 | return (1); | ||
616 | |||
617 | if ((buf = BUF_MEM_new()) == NULL) | ||
618 | goto err; | ||
619 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) | ||
620 | goto err; | ||
621 | |||
622 | s->init_buf = buf; | ||
623 | return (1); | ||
624 | |||
625 | err: | ||
626 | BUF_MEM_free(buf); | ||
627 | return (0); | ||
628 | } | ||
629 | |||
630 | int | ||
610 | ssl3_setup_read_buffer(SSL *s) | 631 | ssl3_setup_read_buffer(SSL *s) |
611 | { | 632 | { |
612 | unsigned char *p; | 633 | unsigned char *p; |
@@ -673,7 +694,6 @@ err: | |||
673 | return 0; | 694 | return 0; |
674 | } | 695 | } |
675 | 696 | ||
676 | |||
677 | int | 697 | int |
678 | ssl3_setup_buffers(SSL *s) | 698 | ssl3_setup_buffers(SSL *s) |
679 | { | 699 | { |
@@ -699,4 +719,3 @@ ssl3_release_read_buffer(SSL *s) | |||
699 | s->s3->rbuf.buf = NULL; | 719 | s->s3->rbuf.buf = NULL; |
700 | return 1; | 720 | return 1; |
701 | } | 721 | } |
702 | |||
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index 5d9ac2e2e8..07d2eb583a 100644 --- a/src/lib/libssl/s3_clnt.c +++ b/src/lib/libssl/s3_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_clnt.c,v 1.109 2015/03/11 19:34:06 tedu Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.110 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -218,7 +218,6 @@ ssl3_get_client_method(int ver) | |||
218 | int | 218 | int |
219 | ssl3_connect(SSL *s) | 219 | ssl3_connect(SSL *s) |
220 | { | 220 | { |
221 | BUF_MEM *buf = NULL; | ||
222 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | 221 | void (*cb)(const SSL *ssl, int type, int val) = NULL; |
223 | int ret = -1; | 222 | int ret = -1; |
224 | int new_state, state, skip = 0; | 223 | int new_state, state, skip = 0; |
@@ -263,26 +262,14 @@ ssl3_connect(SSL *s) | |||
263 | /* s->version=SSL3_VERSION; */ | 262 | /* s->version=SSL3_VERSION; */ |
264 | s->type = SSL_ST_CONNECT; | 263 | s->type = SSL_ST_CONNECT; |
265 | 264 | ||
266 | if (s->init_buf == NULL) { | 265 | if (!ssl3_setup_init_buffer(s)) { |
267 | if ((buf = BUF_MEM_new()) == NULL) { | 266 | ret = -1; |
268 | ret = -1; | 267 | goto end; |
269 | goto end; | ||
270 | } | ||
271 | if (!BUF_MEM_grow(buf, | ||
272 | SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
273 | ret = -1; | ||
274 | goto end; | ||
275 | } | ||
276 | s->init_buf = buf; | ||
277 | buf = NULL; | ||
278 | } | 268 | } |
279 | |||
280 | if (!ssl3_setup_buffers(s)) { | 269 | if (!ssl3_setup_buffers(s)) { |
281 | ret = -1; | 270 | ret = -1; |
282 | goto end; | 271 | goto end; |
283 | } | 272 | } |
284 | |||
285 | /* setup buffing BIO */ | ||
286 | if (!ssl_init_wbio_buffer(s, 0)) { | 273 | if (!ssl_init_wbio_buffer(s, 0)) { |
287 | ret = -1; | 274 | ret = -1; |
288 | goto end; | 275 | goto end; |
@@ -631,12 +618,12 @@ ssl3_connect(SSL *s) | |||
631 | } | 618 | } |
632 | skip = 0; | 619 | skip = 0; |
633 | } | 620 | } |
621 | |||
634 | end: | 622 | end: |
635 | s->in_handshake--; | 623 | s->in_handshake--; |
636 | if (buf != NULL) | ||
637 | BUF_MEM_free(buf); | ||
638 | if (cb != NULL) | 624 | if (cb != NULL) |
639 | cb(s, SSL_CB_CONNECT_EXIT, ret); | 625 | cb(s, SSL_CB_CONNECT_EXIT, ret); |
626 | |||
640 | return (ret); | 627 | return (ret); |
641 | } | 628 | } |
642 | 629 | ||
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c index 0bff0204d9..ce48809f65 100644 --- a/src/lib/libssl/s3_srvr.c +++ b/src/lib/libssl/s3_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_srvr.c,v 1.100 2015/02/25 03:49:21 bcook Exp $ */ | 1 | /* $OpenBSD: s3_srvr.c,v 1.101 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -265,21 +265,10 @@ ssl3_accept(SSL *s) | |||
265 | } | 265 | } |
266 | s->type = SSL_ST_ACCEPT; | 266 | s->type = SSL_ST_ACCEPT; |
267 | 267 | ||
268 | if (s->init_buf == NULL) { | 268 | if (!ssl3_setup_init_buffer(s)) { |
269 | BUF_MEM *buf; | 269 | ret = -1; |
270 | if ((buf = BUF_MEM_new()) == NULL) { | 270 | goto end; |
271 | ret = -1; | ||
272 | goto end; | ||
273 | } | ||
274 | if (!BUF_MEM_grow(buf, | ||
275 | SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
276 | BUF_MEM_free(buf); | ||
277 | ret = -1; | ||
278 | goto end; | ||
279 | } | ||
280 | s->init_buf = buf; | ||
281 | } | 271 | } |
282 | |||
283 | if (!ssl3_setup_buffers(s)) { | 272 | if (!ssl3_setup_buffers(s)) { |
284 | ret = -1; | 273 | ret = -1; |
285 | goto end; | 274 | goto end; |
diff --git a/src/lib/libssl/src/ssl/d1_clnt.c b/src/lib/libssl/src/ssl/d1_clnt.c index cf25183de5..e44c8a0c94 100644 --- a/src/lib/libssl/src/ssl/d1_clnt.c +++ b/src/lib/libssl/src/ssl/d1_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_clnt.c,v 1.43 2015/02/09 10:53:28 jsing Exp $ */ | 1 | /* $OpenBSD: d1_clnt.c,v 1.44 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -176,7 +176,6 @@ dtls1_get_client_method(int ver) | |||
176 | int | 176 | int |
177 | dtls1_connect(SSL *s) | 177 | dtls1_connect(SSL *s) |
178 | { | 178 | { |
179 | BUF_MEM *buf = NULL; | ||
180 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | 179 | void (*cb)(const SSL *ssl, int type, int val) = NULL; |
181 | int ret = -1; | 180 | int ret = -1; |
182 | int new_state, state, skip = 0; | 181 | int new_state, state, skip = 0; |
@@ -223,25 +222,14 @@ dtls1_connect(SSL *s) | |||
223 | /* s->version=SSL3_VERSION; */ | 222 | /* s->version=SSL3_VERSION; */ |
224 | s->type = SSL_ST_CONNECT; | 223 | s->type = SSL_ST_CONNECT; |
225 | 224 | ||
226 | if (s->init_buf == NULL) { | 225 | if (!ssl3_setup_init_buffer(s)) { |
227 | if ((buf = BUF_MEM_new()) == NULL) { | 226 | ret = -1; |
228 | ret = -1; | 227 | goto end; |
229 | goto end; | ||
230 | } | ||
231 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
232 | ret = -1; | ||
233 | goto end; | ||
234 | } | ||
235 | s->init_buf = buf; | ||
236 | buf = NULL; | ||
237 | } | 228 | } |
238 | |||
239 | if (!ssl3_setup_buffers(s)) { | 229 | if (!ssl3_setup_buffers(s)) { |
240 | ret = -1; | 230 | ret = -1; |
241 | goto end; | 231 | goto end; |
242 | } | 232 | } |
243 | |||
244 | /* setup buffing BIO */ | ||
245 | if (!ssl_init_wbio_buffer(s, 0)) { | 233 | if (!ssl_init_wbio_buffer(s, 0)) { |
246 | ret = -1; | 234 | ret = -1; |
247 | goto end; | 235 | goto end; |
@@ -603,14 +591,12 @@ dtls1_connect(SSL *s) | |||
603 | } | 591 | } |
604 | skip = 0; | 592 | skip = 0; |
605 | } | 593 | } |
594 | |||
606 | end: | 595 | end: |
607 | s->in_handshake--; | 596 | s->in_handshake--; |
608 | |||
609 | |||
610 | if (buf != NULL) | ||
611 | BUF_MEM_free(buf); | ||
612 | if (cb != NULL) | 597 | if (cb != NULL) |
613 | cb(s, SSL_CB_CONNECT_EXIT, ret); | 598 | cb(s, SSL_CB_CONNECT_EXIT, ret); |
599 | |||
614 | return (ret); | 600 | return (ret); |
615 | } | 601 | } |
616 | 602 | ||
diff --git a/src/lib/libssl/src/ssl/d1_srvr.c b/src/lib/libssl/src/ssl/d1_srvr.c index 4e6d0da3b3..1d3779f567 100644 --- a/src/lib/libssl/src/ssl/d1_srvr.c +++ b/src/lib/libssl/src/ssl/d1_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_srvr.c,v 1.49 2015/02/09 10:53:28 jsing Exp $ */ | 1 | /* $OpenBSD: d1_srvr.c,v 1.50 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -228,20 +228,10 @@ dtls1_accept(SSL *s) | |||
228 | } | 228 | } |
229 | s->type = SSL_ST_ACCEPT; | 229 | s->type = SSL_ST_ACCEPT; |
230 | 230 | ||
231 | if (s->init_buf == NULL) { | 231 | if (!ssl3_setup_init_buffer(s)) { |
232 | BUF_MEM *buf; | 232 | ret = -1; |
233 | if ((buf = BUF_MEM_new()) == NULL) { | 233 | goto end; |
234 | ret = -1; | ||
235 | goto end; | ||
236 | } | ||
237 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
238 | BUF_MEM_free(buf); | ||
239 | ret = -1; | ||
240 | goto end; | ||
241 | } | ||
242 | s->init_buf = buf; | ||
243 | } | 234 | } |
244 | |||
245 | if (!ssl3_setup_buffers(s)) { | 235 | if (!ssl3_setup_buffers(s)) { |
246 | ret = -1; | 236 | ret = -1; |
247 | goto end; | 237 | goto end; |
diff --git a/src/lib/libssl/src/ssl/s23_clnt.c b/src/lib/libssl/src/ssl/s23_clnt.c index 4159ae0580..0ab56fa38d 100644 --- a/src/lib/libssl/src/ssl/s23_clnt.c +++ b/src/lib/libssl/src/ssl/s23_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s23_clnt.c,v 1.36 2015/02/06 08:30:23 jsing Exp $ */ | 1 | /* $OpenBSD: s23_clnt.c,v 1.37 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -176,7 +176,6 @@ ssl23_get_client_method(int ver) | |||
176 | int | 176 | int |
177 | ssl23_connect(SSL *s) | 177 | ssl23_connect(SSL *s) |
178 | { | 178 | { |
179 | BUF_MEM *buf = NULL; | ||
180 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | 179 | void (*cb)(const SSL *ssl, int type, int val) = NULL; |
181 | int ret = -1; | 180 | int ret = -1; |
182 | int new_state, state; | 181 | int new_state, state; |
@@ -214,24 +213,14 @@ ssl23_connect(SSL *s) | |||
214 | /* s->version=TLS1_VERSION; */ | 213 | /* s->version=TLS1_VERSION; */ |
215 | s->type = SSL_ST_CONNECT; | 214 | s->type = SSL_ST_CONNECT; |
216 | 215 | ||
217 | if (s->init_buf == NULL) { | 216 | if (!ssl3_setup_init_buffer(s)) { |
218 | if ((buf = BUF_MEM_new()) == NULL) { | 217 | ret = -1; |
219 | ret = -1; | 218 | goto end; |
220 | goto end; | ||
221 | } | ||
222 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
223 | ret = -1; | ||
224 | goto end; | ||
225 | } | ||
226 | s->init_buf = buf; | ||
227 | buf = NULL; | ||
228 | } | 219 | } |
229 | |||
230 | if (!ssl3_setup_buffers(s)) { | 220 | if (!ssl3_setup_buffers(s)) { |
231 | ret = -1; | 221 | ret = -1; |
232 | goto end; | 222 | goto end; |
233 | } | 223 | } |
234 | |||
235 | if (!ssl3_init_finished_mac(s)) { | 224 | if (!ssl3_init_finished_mac(s)) { |
236 | ret = -1; | 225 | ret = -1; |
237 | goto end; | 226 | goto end; |
@@ -280,12 +269,12 @@ ssl23_connect(SSL *s) | |||
280 | s->state = new_state; | 269 | s->state = new_state; |
281 | } | 270 | } |
282 | } | 271 | } |
272 | |||
283 | end: | 273 | end: |
284 | s->in_handshake--; | 274 | s->in_handshake--; |
285 | if (buf != NULL) | ||
286 | BUF_MEM_free(buf); | ||
287 | if (cb != NULL) | 275 | if (cb != NULL) |
288 | cb(s, SSL_CB_CONNECT_EXIT, ret); | 276 | cb(s, SSL_CB_CONNECT_EXIT, ret); |
277 | |||
289 | return (ret); | 278 | return (ret); |
290 | } | 279 | } |
291 | 280 | ||
diff --git a/src/lib/libssl/src/ssl/s23_srvr.c b/src/lib/libssl/src/ssl/s23_srvr.c index 9e0ee453db..99bfaf07e4 100644 --- a/src/lib/libssl/src/ssl/s23_srvr.c +++ b/src/lib/libssl/src/ssl/s23_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s23_srvr.c,v 1.38 2015/02/06 08:30:23 jsing Exp $ */ | 1 | /* $OpenBSD: s23_srvr.c,v 1.39 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -207,20 +207,10 @@ ssl23_accept(SSL *s) | |||
207 | /* s->version=SSL3_VERSION; */ | 207 | /* s->version=SSL3_VERSION; */ |
208 | s->type = SSL_ST_ACCEPT; | 208 | s->type = SSL_ST_ACCEPT; |
209 | 209 | ||
210 | if (s->init_buf == NULL) { | 210 | if (!ssl3_setup_init_buffer(s)) { |
211 | BUF_MEM *buf; | 211 | ret = -1; |
212 | if ((buf = BUF_MEM_new()) == NULL) { | 212 | goto end; |
213 | ret = -1; | ||
214 | goto end; | ||
215 | } | ||
216 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
217 | BUF_MEM_free(buf); | ||
218 | ret = -1; | ||
219 | goto end; | ||
220 | } | ||
221 | s->init_buf = buf; | ||
222 | } | 213 | } |
223 | |||
224 | if (!ssl3_init_finished_mac(s)) { | 214 | if (!ssl3_init_finished_mac(s)) { |
225 | ret = -1; | 215 | ret = -1; |
226 | goto end; | 216 | goto end; |
@@ -255,10 +245,12 @@ ssl23_accept(SSL *s) | |||
255 | s->state = new_state; | 245 | s->state = new_state; |
256 | } | 246 | } |
257 | } | 247 | } |
248 | |||
258 | end: | 249 | end: |
259 | s->in_handshake--; | 250 | s->in_handshake--; |
260 | if (cb != NULL) | 251 | if (cb != NULL) |
261 | cb(s, SSL_CB_ACCEPT_EXIT, ret); | 252 | cb(s, SSL_CB_ACCEPT_EXIT, ret); |
253 | |||
262 | return (ret); | 254 | return (ret); |
263 | } | 255 | } |
264 | 256 | ||
diff --git a/src/lib/libssl/src/ssl/s3_both.c b/src/lib/libssl/src/ssl/s3_both.c index a2ce9e9fa3..633bf5bb7b 100644 --- a/src/lib/libssl/src/ssl/s3_both.c +++ b/src/lib/libssl/src/ssl/s3_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_both.c,v 1.37 2014/12/14 21:49:29 bcook Exp $ */ | 1 | /* $OpenBSD: s3_both.c,v 1.38 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -607,6 +607,27 @@ ssl_verify_alarm_type(long type) | |||
607 | } | 607 | } |
608 | 608 | ||
609 | int | 609 | int |
610 | ssl3_setup_init_buffer(SSL *s) | ||
611 | { | ||
612 | BUF_MEM *buf = NULL; | ||
613 | |||
614 | if (s->init_buf != NULL) | ||
615 | return (1); | ||
616 | |||
617 | if ((buf = BUF_MEM_new()) == NULL) | ||
618 | goto err; | ||
619 | if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) | ||
620 | goto err; | ||
621 | |||
622 | s->init_buf = buf; | ||
623 | return (1); | ||
624 | |||
625 | err: | ||
626 | BUF_MEM_free(buf); | ||
627 | return (0); | ||
628 | } | ||
629 | |||
630 | int | ||
610 | ssl3_setup_read_buffer(SSL *s) | 631 | ssl3_setup_read_buffer(SSL *s) |
611 | { | 632 | { |
612 | unsigned char *p; | 633 | unsigned char *p; |
@@ -673,7 +694,6 @@ err: | |||
673 | return 0; | 694 | return 0; |
674 | } | 695 | } |
675 | 696 | ||
676 | |||
677 | int | 697 | int |
678 | ssl3_setup_buffers(SSL *s) | 698 | ssl3_setup_buffers(SSL *s) |
679 | { | 699 | { |
@@ -699,4 +719,3 @@ ssl3_release_read_buffer(SSL *s) | |||
699 | s->s3->rbuf.buf = NULL; | 719 | s->s3->rbuf.buf = NULL; |
700 | return 1; | 720 | return 1; |
701 | } | 721 | } |
702 | |||
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c index 5d9ac2e2e8..07d2eb583a 100644 --- a/src/lib/libssl/src/ssl/s3_clnt.c +++ b/src/lib/libssl/src/ssl/s3_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_clnt.c,v 1.109 2015/03/11 19:34:06 tedu Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.110 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -218,7 +218,6 @@ ssl3_get_client_method(int ver) | |||
218 | int | 218 | int |
219 | ssl3_connect(SSL *s) | 219 | ssl3_connect(SSL *s) |
220 | { | 220 | { |
221 | BUF_MEM *buf = NULL; | ||
222 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | 221 | void (*cb)(const SSL *ssl, int type, int val) = NULL; |
223 | int ret = -1; | 222 | int ret = -1; |
224 | int new_state, state, skip = 0; | 223 | int new_state, state, skip = 0; |
@@ -263,26 +262,14 @@ ssl3_connect(SSL *s) | |||
263 | /* s->version=SSL3_VERSION; */ | 262 | /* s->version=SSL3_VERSION; */ |
264 | s->type = SSL_ST_CONNECT; | 263 | s->type = SSL_ST_CONNECT; |
265 | 264 | ||
266 | if (s->init_buf == NULL) { | 265 | if (!ssl3_setup_init_buffer(s)) { |
267 | if ((buf = BUF_MEM_new()) == NULL) { | 266 | ret = -1; |
268 | ret = -1; | 267 | goto end; |
269 | goto end; | ||
270 | } | ||
271 | if (!BUF_MEM_grow(buf, | ||
272 | SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
273 | ret = -1; | ||
274 | goto end; | ||
275 | } | ||
276 | s->init_buf = buf; | ||
277 | buf = NULL; | ||
278 | } | 268 | } |
279 | |||
280 | if (!ssl3_setup_buffers(s)) { | 269 | if (!ssl3_setup_buffers(s)) { |
281 | ret = -1; | 270 | ret = -1; |
282 | goto end; | 271 | goto end; |
283 | } | 272 | } |
284 | |||
285 | /* setup buffing BIO */ | ||
286 | if (!ssl_init_wbio_buffer(s, 0)) { | 273 | if (!ssl_init_wbio_buffer(s, 0)) { |
287 | ret = -1; | 274 | ret = -1; |
288 | goto end; | 275 | goto end; |
@@ -631,12 +618,12 @@ ssl3_connect(SSL *s) | |||
631 | } | 618 | } |
632 | skip = 0; | 619 | skip = 0; |
633 | } | 620 | } |
621 | |||
634 | end: | 622 | end: |
635 | s->in_handshake--; | 623 | s->in_handshake--; |
636 | if (buf != NULL) | ||
637 | BUF_MEM_free(buf); | ||
638 | if (cb != NULL) | 624 | if (cb != NULL) |
639 | cb(s, SSL_CB_CONNECT_EXIT, ret); | 625 | cb(s, SSL_CB_CONNECT_EXIT, ret); |
626 | |||
640 | return (ret); | 627 | return (ret); |
641 | } | 628 | } |
642 | 629 | ||
diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c index 0bff0204d9..ce48809f65 100644 --- a/src/lib/libssl/src/ssl/s3_srvr.c +++ b/src/lib/libssl/src/ssl/s3_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_srvr.c,v 1.100 2015/02/25 03:49:21 bcook Exp $ */ | 1 | /* $OpenBSD: s3_srvr.c,v 1.101 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -265,21 +265,10 @@ ssl3_accept(SSL *s) | |||
265 | } | 265 | } |
266 | s->type = SSL_ST_ACCEPT; | 266 | s->type = SSL_ST_ACCEPT; |
267 | 267 | ||
268 | if (s->init_buf == NULL) { | 268 | if (!ssl3_setup_init_buffer(s)) { |
269 | BUF_MEM *buf; | 269 | ret = -1; |
270 | if ((buf = BUF_MEM_new()) == NULL) { | 270 | goto end; |
271 | ret = -1; | ||
272 | goto end; | ||
273 | } | ||
274 | if (!BUF_MEM_grow(buf, | ||
275 | SSL3_RT_MAX_PLAIN_LENGTH)) { | ||
276 | BUF_MEM_free(buf); | ||
277 | ret = -1; | ||
278 | goto end; | ||
279 | } | ||
280 | s->init_buf = buf; | ||
281 | } | 271 | } |
282 | |||
283 | if (!ssl3_setup_buffers(s)) { | 272 | if (!ssl3_setup_buffers(s)) { |
284 | ret = -1; | 273 | ret = -1; |
285 | goto end; | 274 | goto end; |
diff --git a/src/lib/libssl/src/ssl/ssl_locl.h b/src/lib/libssl/src/ssl/ssl_locl.h index c38aa3a90d..cb1da576f4 100644 --- a/src/lib/libssl/src/ssl/ssl_locl.h +++ b/src/lib/libssl/src/ssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.88 2015/02/22 15:54:27 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.89 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -637,6 +637,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x); | |||
637 | SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt, | 637 | SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt, |
638 | STACK_OF(SSL_CIPHER) *srvr); | 638 | STACK_OF(SSL_CIPHER) *srvr); |
639 | int ssl3_setup_buffers(SSL *s); | 639 | int ssl3_setup_buffers(SSL *s); |
640 | int ssl3_setup_init_buffer(SSL *s); | ||
640 | int ssl3_setup_read_buffer(SSL *s); | 641 | int ssl3_setup_read_buffer(SSL *s); |
641 | int ssl3_setup_write_buffer(SSL *s); | 642 | int ssl3_setup_write_buffer(SSL *s); |
642 | int ssl3_release_read_buffer(SSL *s); | 643 | int ssl3_release_read_buffer(SSL *s); |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index c38aa3a90d..cb1da576f4 100644 --- a/src/lib/libssl/ssl_locl.h +++ b/src/lib/libssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.88 2015/02/22 15:54:27 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.89 2015/03/27 12:29:54 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -637,6 +637,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x); | |||
637 | SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt, | 637 | SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt, |
638 | STACK_OF(SSL_CIPHER) *srvr); | 638 | STACK_OF(SSL_CIPHER) *srvr); |
639 | int ssl3_setup_buffers(SSL *s); | 639 | int ssl3_setup_buffers(SSL *s); |
640 | int ssl3_setup_init_buffer(SSL *s); | ||
640 | int ssl3_setup_read_buffer(SSL *s); | 641 | int ssl3_setup_read_buffer(SSL *s); |
641 | int ssl3_setup_write_buffer(SSL *s); | 642 | int ssl3_setup_write_buffer(SSL *s); |
642 | int ssl3_release_read_buffer(SSL *s); | 643 | int ssl3_release_read_buffer(SSL *s); |