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 /src/lib/libssl/s3_clnt.c | |
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@
Diffstat (limited to 'src/lib/libssl/s3_clnt.c')
-rw-r--r-- | src/lib/libssl/s3_clnt.c | 25 |
1 files changed, 6 insertions, 19 deletions
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 | ||