summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_clnt.c
diff options
context:
space:
mode:
authorjsing <>2015-03-27 12:29:54 +0000
committerjsing <>2015-03-27 12:29:54 +0000
commit87dfb52384d6fa9cdb7418cfc6f81f1a121e862b (patch)
treed1107e1e9c18e2392e54fb1e385c31262c4dbd2e /src/lib/libssl/d1_clnt.c
parented007e156e0546eb8a587a5b57c7e0509ea52a2c (diff)
downloadopenbsd-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/d1_clnt.c')
-rw-r--r--src/lib/libssl/d1_clnt.c26
1 files changed, 6 insertions, 20 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)
176int 176int
177dtls1_connect(SSL *s) 177dtls1_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
606end: 595end:
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