From 6d381a6c7f9789ec4e22228c47ea78a2c09a3d10 Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Sun, 25 Apr 2021 10:25:56 +0900 Subject: [PATCH] do nothing when version is zero --- src/ssl.c | 8 ++++++++ tests/api.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/ssl.c b/src/ssl.c index 03d61ad64..1167a4f57 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -46251,9 +46251,17 @@ long wolfSSL_CTX_ctrl(WOLFSSL_CTX* ctx, int cmd, long opt, void* pt) break; case SSL_CTRL_SET_MIN_PROTO_VERSION: WOLFSSL_MSG("set min proto version"); + if (opt == 0) { + /* do nothing */ + return WOLFSSL_SUCCESS; + } return wolfSSL_CTX_set_min_proto_version(ctx, (int)opt); case SSL_CTRL_SET_MAX_PROTO_VERSION: WOLFSSL_MSG("set max proto version"); + if (opt == 0) { + /* do nothing */ + return WOLFSSL_SUCCESS; + } return wolfSSL_CTX_set_max_proto_version(ctx, (int)opt); default: WOLFSSL_MSG("CTX_ctrl cmd not implemented"); diff --git a/tests/api.c b/tests/api.c index 618e5be89..15fe861b7 100644 --- a/tests/api.c +++ b/tests/api.c @@ -35940,11 +35940,17 @@ static void test_wolfSSL_CTX_ctrl(void) /* Test for min/max proto */ #ifndef WOLFSSL_NO_TLS12 + AssertIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, + 0, NULL), SSL_SUCCESS); AssertIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, TLS1_2_VERSION, NULL), SSL_SUCCESS); AssertIntEQ(wolfSSL_CTX_get_min_proto_version(ctx), TLS1_2_VERSION); + #endif #ifdef WOLFSSL_TLS13 + AssertIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, + 0, NULL), SSL_SUCCESS); + AssertIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, TLS1_3_VERSION, NULL), SSL_SUCCESS); #endif