diff options
| author | jsing <> | 2015-03-27 12:29:54 +0000 | 
|---|---|---|
| committer | jsing <> | 2015-03-27 12:29:54 +0000 | 
| commit | e4bb8802504ce04db08be8266b9377e800301e84 (patch) | |
| tree | d1107e1e9c18e2392e54fb1e385c31262c4dbd2e /src/lib/libssl/s23_clnt.c | |
| parent | 3c33e1429e1b0d6e6a121c97b536af97a1fd8e0a (diff) | |
| download | openbsd-e4bb8802504ce04db08be8266b9377e800301e84.tar.gz openbsd-e4bb8802504ce04db08be8266b9377e800301e84.tar.bz2 openbsd-e4bb8802504ce04db08be8266b9377e800301e84.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/s23_clnt.c')
| -rw-r--r-- | src/lib/libssl/s23_clnt.c | 23 | 
1 files changed, 6 insertions, 17 deletions
| 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 | ||
