From: "cron2 (Code Review)" Date: Fri, 26 Sep 2025 20:50:36 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., max@...2606... Message-ID: <63934d2131c53f0b4a1b75451dd0493c919e89cc-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Ei/YYzGM/1w="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: ssl_openssl: Use uint16_t internally for TLS versions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos , MaxF Cc: openvpn-devel --Ei/YYzGM/1w= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#3) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1212?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by MaxF Change subject: ssl_openssl: Use uint16_t internally for TLS versions ...................................................................... ssl_openssl: Use uint16_t internally for TLS versions libressl changed the API for the involved functions. Since uint16_t is a true subset of int it should be safe to switch to that for all OpenSSL variants. One trivial drive-by fix in unrelated code to be able to enable -Wconversion fully for the file. This just adds a cast where the comment says we intend a cast. Change-Id: I9ea87531afb553f789289787403900a4758b8e1c Signed-off-by: Frank Lichtenheld Acked-by: MaxF Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1212 Message-Id: <20250924150300.29318-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59238230/ Signed-off-by: Gert Doering --- M src/openvpn/ssl_openssl.c 1 file changed, 7 insertions(+), 25 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/12/1212/3 diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index 89deeaa..434df7d 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -235,8 +235,8 @@ } /** Convert internal version number to openssl version number */ -static int -openssl_tls_version(int ver) +static uint16_t +openssl_tls_version(unsigned int ver) { if (ver =3D=3D TLS_VER_1_0) { @@ -272,23 +272,18 @@ return 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static bool tls_ctx_set_tls_versions(struct tls_root_ctx *ctx, unsigned int ssl_flags) { - int tls_ver_min =3D + uint16_t tls_ver_min =3D openssl_tls_version((ssl_flags >> SSLF_TLS_VERSION_MIN_SHIFT) & SS= LF_TLS_VERSION_MIN_MASK); - int tls_ver_max =3D + uint16_t tls_ver_max =3D openssl_tls_version((ssl_flags >> SSLF_TLS_VERSION_MAX_SHIFT) & SS= LF_TLS_VERSION_MAX_MASK); if (!tls_ver_min) { /* Enforce at least TLS 1.0 */ - int cur_min =3D SSL_CTX_get_min_proto_version(ctx->ctx); + uint16_t cur_min =3D (uint16_t)SSL_CTX_get_min_proto_version(ctx->= ctx); tls_ver_min =3D cur_min < TLS1_VERSION ? TLS1_VERSION : cur_min; } @@ -387,7 +382,7 @@ /* %.*s format specifier expects length of type int, so guaran= tee */ /* that length is small enough and cast to int. */ msg(D_LOW, "No valid translation found for TLS cipher '%.*s'", - constrain_int(current_cipher_len, 0, 256), current_cipher); + constrain_int((int)current_cipher_len, 0, 256), current_ci= pher); } else { @@ -429,10 +424,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers) { @@ -2522,11 +2513,6 @@ msg(D_HANDSHAKE, "%s%s%s%s%s", s1, s2, s3, s4, s5); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - void show_available_tls_ciphers_list(const char *cipher_list, const char *tls_c= ert_profile, bool tls13) { @@ -2541,7 +2527,7 @@ #if defined(TLS1_3_VERSION) if (tls13) { - SSL_CTX_set_min_proto_version(tls_ctx.ctx, openssl_tls_version(TLS= _VER_1_3)); + SSL_CTX_set_min_proto_version(tls_ctx.ctx, TLS1_3_VERSION); tls_ctx_restrict_ciphers_tls13(&tls_ctx, cipher_list); } else @@ -2594,10 +2580,6 @@ SSL_CTX_free(tls_ctx.ctx); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * Show the Elliptic curves that are available for us to use * in the OpenSSL library. -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1212?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I9ea87531afb553f789289787403900a4758b8e1c Gerrit-Change-Number: 1212 Gerrit-PatchSet: 3 Gerrit-Owner: flichtenheld Gerrit-Reviewer: MaxF Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --Ei/YYzGM/1w= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #3 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outd= ated and were removed: Code-Review+2 by MaxF

ssl_openssl: Use uint16_t internally for TLS versions=


libressl changed the API for the involved functions. Since
uint1= 6_t is a true subset of int it should be safe to switch
to that for all = OpenSSL variants.

One trivial drive-by fix in unrelated code to be a= ble
to enable -Wconversion fully for the file. This just
adds a cast = where the comment says we intend a cast.

Change-Id: I9ea87531afb553f= 789289787403900a4758b8e1c
Signed-off-by: Frank Lichtenheld <frank@...493...= 2641...>
Acked-by: MaxF <max@...2606...>
Gerrit URL: https:/= /gerrit.openvpn.net/c/openvpn/+/1212
Message-Id: <20250924150300.2931= 8-1-gert@...1296...>
URL: https://sourceforge.net/p/openvpn/mailman/m= essage/59238230/
Signed-off-by: Gert Doering <gert@...1296...>
= ---
M src/openvpn/ssl_openssl.c
1 file changed, 7 insertions(+), 25 d= eletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/=
changes/12/1212/3
diff --git a/src/openvpn/ssl_openssl.c b/src/open=
vpn/ssl_openssl.c
index 89deeaa..434df7d 100644
<= span>--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_= openssl.c
@@ -235,8 +235,8 @@
}
=
/** Convert internal version number to openssl ver= sion number */
-static = int
-openssl_tls_versio= n(int ver)
+static ui= nt16_t
+openssl_tls_v= ersion(unsigned int ver)
{
if (ver = =3D=3D TLS_VER_1_0)
{
@@ -272,23 +272,= 18 @@
return 0;
}

-#if defined(__GNUC__) |= | defined(__clang__)
-#= pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif

-
static bool
tls_= ctx_set_tls_versions(struct tls_root_ctx *ctx, unsigned int ssl_flags)
{
- int= tls_ver_min =3D
+ = uint16_t tls_ver_min =3D
openssl_tls_version((ssl= _flags >> SSLF_TLS_VERSION_MIN_SHIFT) & SSLF_TLS_VERSION_MIN_MASK= );
- int tls_ver_max= =3D
+ uint16_t tl= s_ver_max =3D
openssl_tls_version((ssl_flags >&= gt; SSLF_TLS_VERSION_MAX_SHIFT) & SSLF_TLS_VERSION_MAX_MASK);
if (!tls_ver_min)
{
/* Enforce at least TLS 1.0 */
- int cur_min =3D SSL_CTX_get_min_pro= to_version(ctx->ctx);
+ uint16_t cur_min =3D (uint16_t)SSL_CTX_get_min_proto_version(c= tx->ctx);
tls_ver_min =3D cur_min < TLS1_VER= SION ? TLS1_VERSION : cur_min;
}

@@ -387,7 +382,7 @@
/* %.*s forma= t specifier expects length of type int, so guarantee */
= /* that length is small enough and cast to int. */
msg(D_LOW, "No valid translation found for TLS cipher &= #39;%.*s'",

- = constrain_int(current_cipher_len, 0, 256), current_cipher);<= /span>
+ cons= train_int((int)current_cipher_len, 0, 256), current_cipher);
}

else
{
@@ -429,10 +424,6 @@
}
}

-#if d= efined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
void
tls_ctx_restrict_ciphers(str= uct tls_root_ctx *ctx, const char *ciphers)
{
@@ -2522,11 +2513,6 @@

msg(D_HANDSHAKE, "%s%s= %s%s%s", s1, s2, s3, s4, s5);
}

-#if defined(__GNUC__) || = defined(__clang__)
-#pr= agma GCC diagnostic push
-#endif
-
void
show_availabl= e_tls_ciphers_list(const char *cipher_list, const char *tls_cert_profile, b= ool tls13)
{
@@ -2541,7 +2527,7 @@<= br> #if defined(TLS1_3_VERSION)
if (tls13)
{
- = SSL_CTX_set_min_proto_version(tls_ctx.ctx, openssl_tls_version(TLS_VER_= 1_3));
+ SSL_C= TX_set_min_proto_version(tls_ctx.ctx, TLS1_3_VERSION);
= tls_ctx_restrict_ciphers_tls13(&tls_ctx, cipher_list);
<= span> }

else
@@ -2594,10 +2580,6 @= @
SSL_CTX_free(tls_ctx.ctx);
}=

-#if define= d(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
/*
* Show the Elliptic curves that ar= e available for us to use
* in the OpenSSL library.

To view, visit change 1212. To unsubscribe, or f= or help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9ea87531afb553f789289787403= 900a4758b8e1c
Gerrit-Change-Number: 1212
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: MaxF <max@...2606...> <= /div>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--Ei/YYzGM/1w=--