summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authorjsing <>2021-02-20 09:43:29 +0000
committerjsing <>2021-02-20 09:43:29 +0000
commitbd364ca9f4fae8a2b7897e24cf7658d9c8d965d3 (patch)
treeb003a2f9929caeeede1312592aff61b58a88eb00 /src/lib/libssl/ssl_lib.c
parent141f3ab66d9950038d21604bc59e4b0055b7983b (diff)
downloadopenbsd-bd364ca9f4fae8a2b7897e24cf7658d9c8d965d3.tar.gz
openbsd-bd364ca9f4fae8a2b7897e24cf7658d9c8d965d3.tar.bz2
openbsd-bd364ca9f4fae8a2b7897e24cf7658d9c8d965d3.zip
Return a min/max version of zero if set to zero.
OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero if the minimum or maximum has been set to zero (which means the minimum or maximum version supported by the method). Previously we returned the minimum or maximum version supported by the method, instead of zero. Match OpenSSL's behaviour by using shadow variables. Discussed with tb@
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r--src/lib/libssl/ssl_lib.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index f802875274..6a182f2e3b 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.246 2021/02/20 08:30:52 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.247 2021/02/20 09:43:29 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 *
@@ -256,6 +256,8 @@ SSL_new(SSL_CTX *ctx)
256 256
257 s->internal->min_version = ctx->internal->min_version; 257 s->internal->min_version = ctx->internal->min_version;
258 s->internal->max_version = ctx->internal->max_version; 258 s->internal->max_version = ctx->internal->max_version;
259 s->internal->min_proto_version = ctx->internal->min_proto_version;
260 s->internal->max_proto_version = ctx->internal->max_proto_version;
259 261
260 s->internal->options = ctx->internal->options; 262 s->internal->options = ctx->internal->options;
261 s->internal->mode = ctx->internal->mode; 263 s->internal->mode = ctx->internal->mode;
@@ -1829,6 +1831,8 @@ SSL_CTX_new(const SSL_METHOD *meth)
1829 ret->method = meth; 1831 ret->method = meth;
1830 ret->internal->min_version = meth->internal->min_version; 1832 ret->internal->min_version = meth->internal->min_version;
1831 ret->internal->max_version = meth->internal->max_version; 1833 ret->internal->max_version = meth->internal->max_version;
1834 ret->internal->min_proto_version = 0;
1835 ret->internal->max_proto_version = 0;
1832 ret->internal->mode = SSL_MODE_AUTO_RETRY; 1836 ret->internal->mode = SSL_MODE_AUTO_RETRY;
1833 1837
1834 ret->cert_store = NULL; 1838 ret->cert_store = NULL;
@@ -3016,52 +3020,56 @@ SSL_cache_hit(SSL *s)
3016int 3020int
3017SSL_CTX_get_min_proto_version(SSL_CTX *ctx) 3021SSL_CTX_get_min_proto_version(SSL_CTX *ctx)
3018{ 3022{
3019 return ctx->internal->min_version; 3023 return ctx->internal->min_proto_version;
3020} 3024}
3021 3025
3022int 3026int
3023SSL_CTX_set_min_proto_version(SSL_CTX *ctx, uint16_t version) 3027SSL_CTX_set_min_proto_version(SSL_CTX *ctx, uint16_t version)
3024{ 3028{
3025 return ssl_version_set_min(ctx->method, version, 3029 return ssl_version_set_min(ctx->method, version,
3026 ctx->internal->max_version, &ctx->internal->min_version); 3030 ctx->internal->max_version, &ctx->internal->min_version,
3031 &ctx->internal->min_proto_version);
3027} 3032}
3028 3033
3029int 3034int
3030SSL_CTX_get_max_proto_version(SSL_CTX *ctx) 3035SSL_CTX_get_max_proto_version(SSL_CTX *ctx)
3031{ 3036{
3032 return ctx->internal->max_version; 3037 return ctx->internal->max_proto_version;
3033} 3038}
3034 3039
3035int 3040int
3036SSL_CTX_set_max_proto_version(SSL_CTX *ctx, uint16_t version) 3041SSL_CTX_set_max_proto_version(SSL_CTX *ctx, uint16_t version)
3037{ 3042{
3038 return ssl_version_set_max(ctx->method, version, 3043 return ssl_version_set_max(ctx->method, version,
3039 ctx->internal->min_version, &ctx->internal->max_version); 3044 ctx->internal->min_version, &ctx->internal->max_version,
3045 &ctx->internal->max_proto_version);
3040} 3046}
3041 3047
3042int 3048int
3043SSL_get_min_proto_version(SSL *ssl) 3049SSL_get_min_proto_version(SSL *ssl)
3044{ 3050{
3045 return ssl->internal->min_version; 3051 return ssl->internal->min_proto_version;
3046} 3052}
3047 3053
3048int 3054int
3049SSL_set_min_proto_version(SSL *ssl, uint16_t version) 3055SSL_set_min_proto_version(SSL *ssl, uint16_t version)
3050{ 3056{
3051 return ssl_version_set_min(ssl->method, version, 3057 return ssl_version_set_min(ssl->method, version,
3052 ssl->internal->max_version, &ssl->internal->min_version); 3058 ssl->internal->max_version, &ssl->internal->min_version,
3059 &ssl->internal->min_proto_version);
3053} 3060}
3054int 3061int
3055SSL_get_max_proto_version(SSL *ssl) 3062SSL_get_max_proto_version(SSL *ssl)
3056{ 3063{
3057 return ssl->internal->max_version; 3064 return ssl->internal->max_proto_version;
3058} 3065}
3059 3066
3060int 3067int
3061SSL_set_max_proto_version(SSL *ssl, uint16_t version) 3068SSL_set_max_proto_version(SSL *ssl, uint16_t version)
3062{ 3069{
3063 return ssl_version_set_max(ssl->method, version, 3070 return ssl_version_set_max(ssl->method, version,
3064 ssl->internal->min_version, &ssl->internal->max_version); 3071 ssl->internal->min_version, &ssl->internal->max_version,
3072 &ssl->internal->max_proto_version);
3065} 3073}
3066 3074
3067static int 3075static int