summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2020-09-15 11:47:49 +0000
committerjsing <>2020-09-15 11:47:49 +0000
commita5f3f173232d9eb13340725d93f9d979eae6167d (patch)
tree6d6079b8478ca27a63c6b895eaa75f67f6dd2c7a
parent08007ba8b24a358556376f4720a481deae2dee22 (diff)
downloadopenbsd-a5f3f173232d9eb13340725d93f9d979eae6167d.tar.gz
openbsd-a5f3f173232d9eb13340725d93f9d979eae6167d.tar.bz2
openbsd-a5f3f173232d9eb13340725d93f9d979eae6167d.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@
-rw-r--r--src/lib/libssl/ssl_lib.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 82c544c620..828aa3a08d 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.227 2020/09/14 18:34:12 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.228 2020/09/15 11:47:49 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 *
@@ -2200,28 +2200,28 @@ SSL_get_ssl_method(SSL *s)
2200} 2200}
2201 2201
2202int 2202int
2203SSL_set_ssl_method(SSL *s, const SSL_METHOD *meth) 2203SSL_set_ssl_method(SSL *s, const SSL_METHOD *method)
2204{ 2204{
2205 int conn = -1; 2205 int (*handshake_func)(SSL *) = NULL;
2206 int ret = 1; 2206 int ret = 1;
2207 2207
2208 if (s->method != meth) { 2208 if (s->method == method)
2209 if (s->internal->handshake_func != NULL) 2209 return (ret);
2210 conn = (s->internal->handshake_func == s->method->internal->ssl_connect);
2211 2210
2212 if (s->method->internal->version == meth->internal->version) 2211 if (s->internal->handshake_func == s->method->internal->ssl_connect)
2213 s->method = meth; 2212 handshake_func = method->internal->ssl_connect;
2214 else { 2213 else if (s->internal->handshake_func == s->method->internal->ssl_accept)
2215 s->method->internal->ssl_free(s); 2214 handshake_func = method->internal->ssl_accept;
2216 s->method = meth;
2217 ret = s->method->internal->ssl_new(s);
2218 }
2219 2215
2220 if (conn == 1) 2216 if (s->method->internal->version == method->internal->version) {
2221 s->internal->handshake_func = meth->internal->ssl_connect; 2217 s->method = method;
2222 else if (conn == 0) 2218 } else {
2223 s->internal->handshake_func = meth->internal->ssl_accept; 2219 s->method->internal->ssl_free(s);
2220 s->method = method;
2221 ret = s->method->internal->ssl_new(s);
2224 } 2222 }
2223 s->internal->handshake_func = handshake_func;
2224
2225 return (ret); 2225 return (ret);
2226} 2226}
2227 2227