diff options
author | 2020-09-15 11:47:49 +0000 | |
---|---|---|
committer | 2020-09-15 11:47:49 +0000 | |
commit | d686ebec5a545fbc6c9e8f0438bdf2c1a890aeda (patch) | |
tree | 77bb047e2a9a1badbc2203a2dfd306279cd6f1e0 /lib/libssl/ssl_lib.c | |
parent | We have sockaddr_storage these days, get rid of isc_sockaddr_t. (diff) | |
download | wireguard-openbsd-d686ebec5a545fbc6c9e8f0438bdf2c1a890aeda.tar.xz wireguard-openbsd-d686ebec5a545fbc6c9e8f0438bdf2c1a890aeda.zip |
Cleanup/simplify SSL_set_ssl_method().
In particular, figure what the handshake_func should be early on, so we
can just assign later.
ok beck@
Diffstat (limited to 'lib/libssl/ssl_lib.c')
-rw-r--r-- | lib/libssl/ssl_lib.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c index 82c544c6204..828aa3a08d0 100644 --- a/lib/libssl/ssl_lib.c +++ b/lib/libssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.227 2020/09/14 18:34:12 jsing Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.228 2020/09/15 11:47:49 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -2200,28 +2200,28 @@ SSL_get_ssl_method(SSL *s) } int -SSL_set_ssl_method(SSL *s, const SSL_METHOD *meth) +SSL_set_ssl_method(SSL *s, const SSL_METHOD *method) { - int conn = -1; - int ret = 1; + int (*handshake_func)(SSL *) = NULL; + int ret = 1; - if (s->method != meth) { - if (s->internal->handshake_func != NULL) - conn = (s->internal->handshake_func == s->method->internal->ssl_connect); + if (s->method == method) + return (ret); - if (s->method->internal->version == meth->internal->version) - s->method = meth; - else { - s->method->internal->ssl_free(s); - s->method = meth; - ret = s->method->internal->ssl_new(s); - } + if (s->internal->handshake_func == s->method->internal->ssl_connect) + handshake_func = method->internal->ssl_connect; + else if (s->internal->handshake_func == s->method->internal->ssl_accept) + handshake_func = method->internal->ssl_accept; - if (conn == 1) - s->internal->handshake_func = meth->internal->ssl_connect; - else if (conn == 0) - s->internal->handshake_func = meth->internal->ssl_accept; + if (s->method->internal->version == method->internal->version) { + s->method = method; + } else { + s->method->internal->ssl_free(s); + s->method = method; + ret = s->method->internal->ssl_new(s); } + s->internal->handshake_func = handshake_func; + return (ret); } |