diff options
| author | jsing <> | 2020-09-15 11:47:49 +0000 |
|---|---|---|
| committer | jsing <> | 2020-09-15 11:47:49 +0000 |
| commit | c36b1536473dcd5e4c47ff8670f988f59b9a2e07 (patch) | |
| tree | 6d6079b8478ca27a63c6b895eaa75f67f6dd2c7a /src | |
| parent | b1c0ef487c250fc4642e7e832c1057881273e6fd (diff) | |
| download | openbsd-c36b1536473dcd5e4c47ff8670f988f59b9a2e07.tar.gz openbsd-c36b1536473dcd5e4c47ff8670f988f59b9a2e07.tar.bz2 openbsd-c36b1536473dcd5e4c47ff8670f988f59b9a2e07.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 'src')
| -rw-r--r-- | src/lib/libssl/ssl_lib.c | 36 |
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 | ||
| 2202 | int | 2202 | int |
| 2203 | SSL_set_ssl_method(SSL *s, const SSL_METHOD *meth) | 2203 | SSL_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 | ||
