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_srvr.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_srvr.c')
-rw-r--r-- | src/lib/libssl/ssl_srvr.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/lib/libssl/ssl_srvr.c b/src/lib/libssl/ssl_srvr.c index 2097ccdebf..a473d5af05 100644 --- a/src/lib/libssl/ssl_srvr.c +++ b/src/lib/libssl/ssl_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_srvr.c,v 1.117 2021/06/29 19:43:15 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_srvr.c,v 1.118 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 | * |
@@ -174,20 +174,14 @@ | |||
174 | int | 174 | int |
175 | ssl3_accept(SSL *s) | 175 | ssl3_accept(SSL *s) |
176 | { | 176 | { |
177 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | ||
178 | unsigned long alg_k; | 177 | unsigned long alg_k; |
179 | int ret = -1; | ||
180 | int new_state, state, skip = 0; | 178 | int new_state, state, skip = 0; |
181 | int listen = 0; | 179 | int listen = 0; |
180 | int ret = -1; | ||
182 | 181 | ||
183 | ERR_clear_error(); | 182 | ERR_clear_error(); |
184 | errno = 0; | 183 | errno = 0; |
185 | 184 | ||
186 | if (s->internal->info_callback != NULL) | ||
187 | cb = s->internal->info_callback; | ||
188 | else if (s->ctx->internal->info_callback != NULL) | ||
189 | cb = s->ctx->internal->info_callback; | ||
190 | |||
191 | if (SSL_is_dtls(s)) | 185 | if (SSL_is_dtls(s)) |
192 | listen = D1I(s)->listen; | 186 | listen = D1I(s)->listen; |
193 | 187 | ||
@@ -212,8 +206,8 @@ ssl3_accept(SSL *s) | |||
212 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: | 206 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: |
213 | case SSL_ST_OK|SSL_ST_ACCEPT: | 207 | case SSL_ST_OK|SSL_ST_ACCEPT: |
214 | s->server = 1; | 208 | s->server = 1; |
215 | if (cb != NULL) | 209 | |
216 | cb(s, SSL_CB_HANDSHAKE_START, 1); | 210 | ssl_info_callback(s, SSL_CB_HANDSHAKE_START, 1); |
217 | 211 | ||
218 | if (!ssl_legacy_stack_version(s, s->version)) { | 212 | if (!ssl_legacy_stack_version(s, s->version)) { |
219 | SSLerror(s, ERR_R_INTERNAL_ERROR); | 213 | SSLerror(s, ERR_R_INTERNAL_ERROR); |
@@ -705,8 +699,7 @@ ssl3_accept(SSL *s) | |||
705 | /* s->server=1; */ | 699 | /* s->server=1; */ |
706 | s->internal->handshake_func = ssl3_accept; | 700 | s->internal->handshake_func = ssl3_accept; |
707 | 701 | ||
708 | if (cb != NULL) | 702 | ssl_info_callback(s, SSL_CB_HANDSHAKE_DONE, 1); |
709 | cb(s, SSL_CB_HANDSHAKE_DONE, 1); | ||
710 | } | 703 | } |
711 | 704 | ||
712 | ret = 1; | 705 | ret = 1; |
@@ -735,10 +728,10 @@ ssl3_accept(SSL *s) | |||
735 | } | 728 | } |
736 | 729 | ||
737 | 730 | ||
738 | if ((cb != NULL) && (S3I(s)->hs.state != state)) { | 731 | if (S3I(s)->hs.state != state) { |
739 | new_state = S3I(s)->hs.state; | 732 | new_state = S3I(s)->hs.state; |
740 | S3I(s)->hs.state = state; | 733 | S3I(s)->hs.state = state; |
741 | cb(s, SSL_CB_ACCEPT_LOOP, 1); | 734 | ssl_info_callback(s, SSL_CB_ACCEPT_LOOP, 1); |
742 | S3I(s)->hs.state = new_state; | 735 | S3I(s)->hs.state = new_state; |
743 | } | 736 | } |
744 | } | 737 | } |
@@ -747,8 +740,7 @@ ssl3_accept(SSL *s) | |||
747 | end: | 740 | end: |
748 | /* BIO_flush(s->wbio); */ | 741 | /* BIO_flush(s->wbio); */ |
749 | s->internal->in_handshake--; | 742 | s->internal->in_handshake--; |
750 | if (cb != NULL) | 743 | ssl_info_callback(s, SSL_CB_ACCEPT_EXIT, ret); |
751 | cb(s, SSL_CB_ACCEPT_EXIT, ret); | ||
752 | 744 | ||
753 | return (ret); | 745 | return (ret); |
754 | } | 746 | } |