diff options
author | jsing <> | 2021-08-30 19:25:43 +0000 |
---|---|---|
committer | jsing <> | 2021-08-30 19:25:43 +0000 |
commit | a376b9cd8ffd396f270e597131a83af4f639bd93 (patch) | |
tree | 8e3bea79ab1dea102b95252a7e2c36c06522e41d /src/lib/libssl/ssl_clnt.c | |
parent | cedbde20c0ecfb870c00ce4fe4401f89a9397b6d (diff) | |
download | openbsd-a376b9cd8ffd396f270e597131a83af4f639bd93.tar.gz openbsd-a376b9cd8ffd396f270e597131a83af4f639bd93.tar.bz2 openbsd-a376b9cd8ffd396f270e597131a83af4f639bd93.zip |
Clean up and simplify info and msg callbacks.
The info and msg callbacks result in duplication - both for code that
refers to the function pointers and for the call sites. Avoid this by
providing typedefs for the function pointers and pulling the calling
sequences into their own functions.
ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/ssl_clnt.c')
-rw-r--r-- | src/lib/libssl/ssl_clnt.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c index 8864909c9e..519e823354 100644 --- a/src/lib/libssl/ssl_clnt.c +++ b/src/lib/libssl/ssl_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_clnt.c,v 1.107 2021/06/30 09:59:07 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_clnt.c,v 1.108 2021/08/30 19:25:43 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 | * |
@@ -179,18 +179,12 @@ static int ca_dn_cmp(const X509_NAME * const *a, const X509_NAME * const *b); | |||
179 | int | 179 | int |
180 | ssl3_connect(SSL *s) | 180 | ssl3_connect(SSL *s) |
181 | { | 181 | { |
182 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | ||
183 | int ret = -1; | ||
184 | int new_state, state, skip = 0; | 182 | int new_state, state, skip = 0; |
183 | int ret = -1; | ||
185 | 184 | ||
186 | ERR_clear_error(); | 185 | ERR_clear_error(); |
187 | errno = 0; | 186 | errno = 0; |
188 | 187 | ||
189 | if (s->internal->info_callback != NULL) | ||
190 | cb = s->internal->info_callback; | ||
191 | else if (s->ctx->internal->info_callback != NULL) | ||
192 | cb = s->ctx->internal->info_callback; | ||
193 | |||
194 | s->internal->in_handshake++; | 188 | s->internal->in_handshake++; |
195 | if (!SSL_in_init(s) || SSL_in_before(s)) | 189 | if (!SSL_in_init(s) || SSL_in_before(s)) |
196 | SSL_clear(s); | 190 | SSL_clear(s); |
@@ -210,8 +204,8 @@ ssl3_connect(SSL *s) | |||
210 | case SSL_ST_OK|SSL_ST_CONNECT: | 204 | case SSL_ST_OK|SSL_ST_CONNECT: |
211 | 205 | ||
212 | s->server = 0; | 206 | s->server = 0; |
213 | if (cb != NULL) | 207 | |
214 | cb(s, SSL_CB_HANDSHAKE_START, 1); | 208 | ssl_info_callback(s, SSL_CB_HANDSHAKE_START, 1); |
215 | 209 | ||
216 | if (!ssl_legacy_stack_version(s, s->version)) { | 210 | if (!ssl_legacy_stack_version(s, s->version)) { |
217 | SSLerror(s, ERR_R_INTERNAL_ERROR); | 211 | SSLerror(s, ERR_R_INTERNAL_ERROR); |
@@ -597,8 +591,7 @@ ssl3_connect(SSL *s) | |||
597 | s->internal->handshake_func = ssl3_connect; | 591 | s->internal->handshake_func = ssl3_connect; |
598 | s->ctx->internal->stats.sess_connect_good++; | 592 | s->ctx->internal->stats.sess_connect_good++; |
599 | 593 | ||
600 | if (cb != NULL) | 594 | ssl_info_callback(s, SSL_CB_HANDSHAKE_DONE, 1); |
601 | cb(s, SSL_CB_HANDSHAKE_DONE, 1); | ||
602 | 595 | ||
603 | if (SSL_is_dtls(s)) { | 596 | if (SSL_is_dtls(s)) { |
604 | /* done with handshaking */ | 597 | /* done with handshaking */ |
@@ -623,10 +616,10 @@ ssl3_connect(SSL *s) | |||
623 | goto end; | 616 | goto end; |
624 | } | 617 | } |
625 | 618 | ||
626 | if ((cb != NULL) && (S3I(s)->hs.state != state)) { | 619 | if (S3I(s)->hs.state != state) { |
627 | new_state = S3I(s)->hs.state; | 620 | new_state = S3I(s)->hs.state; |
628 | S3I(s)->hs.state = state; | 621 | S3I(s)->hs.state = state; |
629 | cb(s, SSL_CB_CONNECT_LOOP, 1); | 622 | ssl_info_callback(s, SSL_CB_CONNECT_LOOP, 1); |
630 | S3I(s)->hs.state = new_state; | 623 | S3I(s)->hs.state = new_state; |
631 | } | 624 | } |
632 | } | 625 | } |
@@ -635,8 +628,7 @@ ssl3_connect(SSL *s) | |||
635 | 628 | ||
636 | end: | 629 | end: |
637 | s->internal->in_handshake--; | 630 | s->internal->in_handshake--; |
638 | if (cb != NULL) | 631 | ssl_info_callback(s, SSL_CB_CONNECT_EXIT, ret); |
639 | cb(s, SSL_CB_CONNECT_EXIT, ret); | ||
640 | 632 | ||
641 | return (ret); | 633 | return (ret); |
642 | } | 634 | } |