From: "cron2 (Code Review)" Date: Wed, 12 Nov 2025 15:54:29 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <04e404c20f25da19e28b19424f91f99d54b3094e-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="dkDisBwVIAY="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: ssl: change return type of calc_control_channel_frame_overhead to size_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --dkDisBwVIAY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#5) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1297?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos Change subject: ssl: change return type of calc_control_channel_frame_overh= ead to size_t ...................................................................... ssl: change return type of calc_control_channel_frame_overhead to size_t This avoids dealing with conversion warnings inside the function. Since we only add values that are supposed to be positive this should be safe. Note that we now cast the return value to int at the caller side. There we actually substract it and want to catch the case where the result gets negative. Since all the involved values are quite small compared to INT_MAX I decided to just cast it without further checks. Change-Id: I71e9d4a61d37483685723c16e98f59755694cadf Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1297 Message-Id: <20251111172437.7634-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 326.html Signed-off-by: Gert Doering --- M src/openvpn/ssl.c 1 file changed, 3 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1297/5 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index e21ac78..d7f55dd 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -179,21 +179,16 @@ frame->tun_mtu =3D max_int(frame->tun_mtu, TLS_CHANNEL_MTU_MIN); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** * calculate the maximum overhead that control channel frames have * This includes header, op code and everything apart from the * payload itself. This method is a bit pessimistic and might give higher * overhead than we actually have */ -static int +static size_t calc_control_channel_frame_overhead(const struct tls_session *session) { const struct key_state *ks =3D &session->key[KS_PRIMARY]; - int overhead =3D 0; + size_t overhead =3D 0; /* opcode */ overhead +=3D 1; @@ -226,10 +221,6 @@ return overhead; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void init_ssl_lib(void) { @@ -2650,7 +2641,7 @@ int max_pkt_len =3D min_int(TLS_CHANNEL_BUF_SIZE, session->opt->frame.= tun_mtu); /* Subtract overhead */ - max_pkt_len -=3D calc_control_channel_frame_overhead(session); + max_pkt_len -=3D (int)calc_control_channel_frame_overhead(session); /* calculate total available length for outgoing tls ciphertext */ int maxlen =3D max_pkt_len * rel_avail; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1297?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I71e9d4a61d37483685723c16e98f59755694cadf Gerrit-Change-Number: 1297 Gerrit-PatchSet: 5 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --dkDisBwVIAY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #5 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by plaisthos

ssl: change return type of calc=
_control_channel_frame_overhead to size_t

This avoids dealing with c= onversion warnings inside
the function. Since we only add values that ar= e
supposed to be positive this should be safe.

Note that we now c= ast the return value to int at
the caller side. There we actually substr= act it and
want to catch the case where the result gets negative.
Sin= ce all the involved values are quite small compared
to INT_MAX I decided= to just cast it without further
checks.

Change-Id: I71e9d4a61d37= 483685723c16e98f59755694cadf
Signed-off-by: Frank Lichtenheld <frank@= ...2641...>
Acked-by: Arne Schwabe <arne-openvpn@...1227...>Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1297
Message-Id: <= ;20251111172437.7634-1-gert@...1296...>
URL: https://www.mail-archive= .com/openvpn-devel@lists.sourceforge.net/msg34326.html
Signed-off-by: Ge= rt Doering <gert@...1296...>
---
M src/openvpn/ssl.c
1 file = changed, 3 insertions(+), 12 deletions(-)

git pu=
ll ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1297/5
di=
ff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index e21a= c78..d7f55dd 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -179,21 +179,16 @@
frame->tun_mtu =3D max_int(frame->tun_mtu, TLS_CHANNEL_MTU_M= IN);
}

-#if defined(__GNUC__) || defined(__clang__)
<= span style=3D"color: hsl(0, 100%, 40%);">-#pragma GCC diagnostic push

-#pragma GCC diagnostic igno= red "-Wconversion"
-#endif
-<= br> /**
* calculate the maximum overhead that contr= ol channel frames have
* This includes header, op code an= d everything apart from the
* payload itself. This method= is a bit pessimistic and might give higher
* overhead th= an we actually have */
= -static int
+static s= ize_t
calc_control_channel_frame_overhead(const struct tls= _session *session)
{
const struct key= _state *ks =3D &session->key[KS_PRIMARY];
- int overhead =3D 0;
+ size_t overhead =3D 0;
=
/* opcode */
overhead +=3D 1;
@@ -226,10 +221,6 @@
return overhead;
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

-
void
init_ssl_l= ib(void)
{
@@ -2650,7 +2641,7 @@ int max_pkt_len =3D min_int(TLS_CHANNEL_BUF_SIZE, session->o= pt->frame.tun_mtu);

/* Subtract o= verhead */
- max_pkt= _len -=3D calc_control_channel_frame_overhead(session);
+ max_pkt_len -=3D (int)calc_control_= channel_frame_overhead(session);

/* = calculate total available length for outgoing tls ciphertext */
<= span> int maxlen =3D max_pkt_len * rel_avail;

To view, visit change 1297. To unsubscribe, or for help writing mail= filters, visit = settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I71e9d4a61d37483685723c16e98= f59755694cadf
Gerrit-Change-Number: 1297
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --dkDisBwVIAY=--