From: "flichtenheld (Code Review)" Date: Mon, 28 Jul 2025 13:53:02 +0000 In-Reply-To: References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <2f7025852bdbea14f52fd23861c74084d093d9b7-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="MMp5zoHdtEY="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: ssl_common: Make sure ssl flags are treated as unsigned List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --MMp5zoHdtEY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1104?usp=3Demail to look at the new patch set (#2). Change subject: ssl_common: Make sure ssl flags are treated as unsigned ...................................................................... ssl_common: Make sure ssl flags are treated as unsigned tls_options.ssl_flags is already unsigned, make sure the flags are as well to avoid spurious conversion warnings. Also fix various warning regarding the use of the flags for TLS version handling. Change-Id: I03e5ece7580ca4ebd41a7928ead544df46e8bad1 Signed-off-by: Frank Lichtenheld --- M src/openvpn/options.c M src/openvpn/ssl_common.h 2 files changed, 20 insertions(+), 22 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/1104/2 diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0662b49..6ad1170 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -2722,14 +2722,14 @@ "may accept clients which do not present a certificate"); } - const int tls_version_max =3D + const unsigned int tls_version_max =3D (options->ssl_flags >> SSLF_TLS_VERSION_MAX_SHIFT) & SSLF_TLS_VERSION_MAX_MASK; - const int tls_version_min =3D + const unsigned int tls_version_min =3D (options->ssl_flags >> SSLF_TLS_VERSION_MIN_SHIFT) & SSLF_TLS_VERSION_MIN_MASK; - if (tls_version_max > 0 && tls_version_max < tls_version_min) + if (tls_version_max < tls_version_min) { msg(M_USAGE, "--tls-version-min bigger than --tls-version-max"); } @@ -3387,12 +3387,12 @@ options_set_backwards_compatible_options(struct options *o) { /* TLS min version is not set */ - int tls_ver_min =3D (o->ssl_flags >> SSLF_TLS_VERSION_MIN_SHIFT) - & SSLF_TLS_VERSION_MIN_MASK; + unsigned int tls_ver_min =3D (o->ssl_flags >> SSLF_TLS_VERSION_MIN_SHI= FT) + & SSLF_TLS_VERSION_MIN_MASK; if (tls_ver_min =3D=3D 0) { - int tls_ver_max =3D (o->ssl_flags >> SSLF_TLS_VERSION_MAX_SHIFT) - & SSLF_TLS_VERSION_MAX_MASK; + unsigned int tls_ver_max =3D (o->ssl_flags >> SSLF_TLS_VERSION_MAX= _SHIFT) + & SSLF_TLS_VERSION_MAX_MASK; if (need_compatibility_before(o, 20307)) { /* 2.3.6 and earlier have TLS 1.0 only, set minimum to TLS 1.0= */ @@ -9074,9 +9074,8 @@ } else if (streq(p[0], "tls-version-min") && p[1] && !p[3]) { - int ver; VERIFY_PERMISSION(OPT_P_GENERAL); - ver =3D tls_version_parse(p[1], p[2]); + int ver =3D tls_version_parse(p[1], p[2]); if (ver =3D=3D TLS_VER_BAD) { msg(msglevel, "unknown tls-version-min parameter: %s", p[1]); @@ -9093,13 +9092,12 @@ options->ssl_flags &=3D ~(SSLF_TLS_VERSION_MIN_MASK << SSLF_TLS_VERSION_MIN_SHIFT); - options->ssl_flags |=3D (ver << SSLF_TLS_VERSION_MIN_SHIFT); + options->ssl_flags |=3D ((unsigned int)ver << SSLF_TLS_VERSION_MIN= _SHIFT); } else if (streq(p[0], "tls-version-max") && p[1] && !p[2]) { - int ver; VERIFY_PERMISSION(OPT_P_GENERAL); - ver =3D tls_version_parse(p[1], NULL); + int ver =3D tls_version_parse(p[1], NULL); if (ver =3D=3D TLS_VER_BAD) { msg(msglevel, "unknown tls-version-max parameter: %s", p[1]); @@ -9107,7 +9105,7 @@ } options->ssl_flags &=3D ~(SSLF_TLS_VERSION_MAX_MASK << SSLF_TLS_VERSION_MAX_SHIFT); - options->ssl_flags |=3D (ver << SSLF_TLS_VERSION_MAX_SHIFT); + options->ssl_flags |=3D ((unsigned int)ver << SSLF_TLS_VERSION_MAX= _SHIFT); } #ifndef ENABLE_CRYPTO_MBEDTLS else if (streq(p[0], "pkcs12") && p[1] && !p[2]) diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index e9e50da..750891c 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -415,17 +415,17 @@ #endif /* configuration file SSL-related boolean and low-permutation options = */ -#define SSLF_CLIENT_CERT_NOT_REQUIRED (1<<0) -#define SSLF_CLIENT_CERT_OPTIONAL (1<<1) -#define SSLF_USERNAME_AS_COMMON_NAME (1<<2) -#define SSLF_AUTH_USER_PASS_OPTIONAL (1<<3) -#define SSLF_OPT_VERIFY (1<<4) -#define SSLF_CRL_VERIFY_DIR (1<<5) +#define SSLF_CLIENT_CERT_NOT_REQUIRED (1u<<0) +#define SSLF_CLIENT_CERT_OPTIONAL (1u<<1) +#define SSLF_USERNAME_AS_COMMON_NAME (1u<<2) +#define SSLF_AUTH_USER_PASS_OPTIONAL (1u<<3) +#define SSLF_OPT_VERIFY (1u<<4) +#define SSLF_CRL_VERIFY_DIR (1u<<5) #define SSLF_TLS_VERSION_MIN_SHIFT 6 -#define SSLF_TLS_VERSION_MIN_MASK 0xF /* (uses bit positions 6 to 9) = */ +#define SSLF_TLS_VERSION_MIN_MASK 0xFu /* (uses bit positions 6 to 9)= */ #define SSLF_TLS_VERSION_MAX_SHIFT 10 -#define SSLF_TLS_VERSION_MAX_MASK 0xF /* (uses bit positions 10 to 13= ) */ -#define SSLF_TLS_DEBUG_ENABLED (1<<14) +#define SSLF_TLS_VERSION_MAX_MASK 0xFu /* (uses bit positions 10 to 1= 3) */ +#define SSLF_TLS_DEBUG_ENABLED (1u<<14) unsigned int ssl_flags; =20 #ifdef ENABLE_MANAGEMENT -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1104?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: I03e5ece7580ca4ebd41a7928ead544df46e8bad1 Gerrit-Change-Number: 1104 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newpatchset --MMp5zoHdtEY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld uploaded patch set #2 to this change.

<= p>View C= hange

ssl_common: Make sure ssl flags are treated as unsigned

tl= s_options.ssl_flags is already unsigned, make sure the
flags are as well= to avoid spurious conversion warnings.

Also fix various warning reg= arding the use of the flags
for TLS version handling.

Change-Id: = I03e5ece7580ca4ebd41a7928ead544df46e8bad1
Signed-off-by: Frank Lichtenhe= ld <frank@...2641...>
---
M src/openvpn/options.c
M src/open= vpn/ssl_common.h
2 files changed, 20 insertions(+), 22 deletions(-)
<= br>
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/1104/=
2
diff --git a/src/openvpn/options.c b/src/openvpn/options.c=

index 0662b49..6ad1170 100644
--- a/src/openvpn/o= ptions.c
+++ b/src/openvpn/options.c
@@ -27= 22,14 +2722,14 @@
"may accept clients whi= ch do not present a certificate");
}

- const int tl= s_version_max =3D
+ = const unsigned int tls_version_max =3D
(options-= >ssl_flags >> SSLF_TLS_VERSION_MAX_SHIFT)
= & SSLF_TLS_VERSION_MAX_MASK;
- const int tls_version_min =3D
+ const unsigned int tls_version_min =3D=
(options->ssl_flags >> SSLF_TLS_VERSION_MIN_SHI= FT)
& SSLF_TLS_VERSION_MIN_MASK;

- if (tls_versi= on_max > 0 && tls_version_max < tls_version_min)
+ if (tls_version_max < tls= _version_min)
{
msg(M_USAGE, = "--tls-version-min bigger than --tls-version-max");
}
@@ -3387,12 +3387,12 @@
options_= set_backwards_compatible_options(struct options *o)
{
/* TLS min version is not set */
- int tls_ver_min =3D (o->ssl_flags >&g= t; SSLF_TLS_VERSION_MIN_SHIFT)
- & SSLF_TLS_VERSION_MIN_MASK;
<= span style=3D"color: hsl(120, 100%, 40%);">+ unsigned int tls_ver_min = =3D (o->ssl_flags >> SSLF_TLS_VERSION_MIN_SHIFT)

+ & SSLF_TLS_VERSION_MIN_MA= SK;
if (tls_ver_min =3D=3D 0)
{
- int tls_ver_max= =3D (o->ssl_flags >> SSLF_TLS_VERSION_MAX_SHIFT)
- & SSLF_T= LS_VERSION_MAX_MASK;
= + unsigned int tls_ver_max =3D (o->ssl_flags >> SSLF_TLS_VE= RSION_MAX_SHIFT)
+ = & SSLF_TLS_VERSION_MAX_MASK;
if (need= _compatibility_before(o, 20307))
{
/* 2.3.6 and earlier have TLS 1.0 only, set minimum to TLS 1.= 0 */

@@ -9074,9 +9074,8 @@
} else if (streq(p[0], "tls-version-min") && p[= 1] && !p[3])
{
- int ver;
VERIFY_PERM= ISSION(OPT_P_GENERAL);
= - ver =3D tls_version_parse(p[1], p[2]);
+ int ver =3D tls_version_parse(p[1], p[2= ]);
if (ver =3D=3D TLS_VER_BAD)
= {
msg(msglevel, "unknown tls-versi= on-min parameter: %s", p[1]);
@@ -9093,13 +9092,12 @@<= /span>

options->ssl_flags &=3D
~(SSLF_TLS_VERSION_MIN_MASK << SSLF_TLS_V= ERSION_MIN_SHIFT);
- = options->ssl_flags |=3D (ver << SSLF_TLS_VERSION_MIN_SHIFT);<= /span>
+ options->= ssl_flags |=3D ((unsigned int)ver << SSLF_TLS_VERSION_MIN_SHIFT);

}
else if (streq(p[0], "tls-ver= sion-max") && p[1] && !p[2])
{

- int ver;<= br> VERIFY_PERMISSION(OPT_P_GENERAL);
- ver =3D tls_version_parse(p[1], NUL= L);
+ int ver = =3D tls_version_parse(p[1], NULL);
if (ver =3D=3D = TLS_VER_BAD)
{
msg(ms= glevel, "unknown tls-version-max parameter: %s", p[1]);@@ -9107,7 +9105,7 @@
}
= options->ssl_flags &=3D
~(SSLF_TL= S_VERSION_MAX_MASK << SSLF_TLS_VERSION_MAX_SHIFT);
- options->ssl_flags |=3D (ver = << SSLF_TLS_VERSION_MAX_SHIFT);
+ options->ssl_flags |=3D ((unsigned int)ver <= ;< SSLF_TLS_VERSION_MAX_SHIFT);
}
= #ifndef ENABLE_CRYPTO_MBEDTLS
else if (streq(p[0], &qu= ot;pkcs12") && p[1] && !p[2])
diff --g= it a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h
in= dex e9e50da..750891c 100644
--- a/src/openvpn/ssl_common.h<= /span>
+++ b/src/openvpn/ssl_common.h
@@ -415,17 += 415,17 @@
#endif

/*= configuration file SSL-related boolean and low-permutation options */
-#define SSLF_CLIENT_CERT_N= OT_REQUIRED (1<<0)
-#define SSLF_USERNAME_AS_COMMON_NAME (1<= ;<2)
-#define SSLF_A= UTH_USER_PASS_OPTIONAL (1<<3)
-#define SSLF_OPT_VERIFY (1<<4)-#define SSLF_CRL_VERIFY_DIR = (1<<5)
+= #define SSLF_CLIENT_CERT_NOT_REQUIRED (1u<<0)
+#define SSLF_CLIENT_CERT_OPTIONAL (1u= <<1)
+#define S= SLF_USERNAME_AS_COMMON_NAME (1u<<2)
+#define SSLF_AUTH_USER_PASS_OPTIONAL (1u<<3)<= /span>
+#define SSLF_OPT_VER= IFY (1u<<4)
+#define SSLF_CRL_VERIFY_DIR (1u<<5)
<= span> #define SSLF_TLS_VERSION_MIN_SHIFT 6

-#define SSLF_TLS_VERSION_MIN_MASK 0xF /* (uses= bit positions 6 to 9) */
+#define SSLF_TLS_VERSION_MIN_MASK 0xFu /* (uses bit positions 6 = to 9) */
#define SSLF_TLS_VERSION_MAX_SHIFT 10-#define SSLF_TLS_VERSION_MAX_M= ASK 0xF /* (uses bit positions 10 to 13) */
-#define SSLF_TLS_DEBUG_ENABLED (1<<= 14)
+#define SSLF_TLS= _VERSION_MAX_MASK 0xFu /* (uses bit positions 10 to 13) */
<= span style=3D"color: hsl(120, 100%, 40%);">+#define SSLF_TLS_DEBUG_ENABLED = (1u<<14)

unsigned int ssl_flags;
#ifdef ENABLE_MANAGEMENT
=

To view, visit change 1104. To unsubscribe, or for help writing ma= il filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I03e5ece7580ca4ebd41a7928ead= 544df46e8bad1
Gerrit-Change-Number: 1104
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-MessageType: newpatchset
--MMp5zoHdtEY=--