From: "flichtenheld (Code Review)" Date: Fri, 24 Oct 2025 16:52:48 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <2e1dd099fb0df6b28cd411711433e0a840548add-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="xRLGa9I4yrA="; 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: plaisthos Cc: openvpn-devel --xRLGa9I4yrA= 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 do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1297?usp=3Demail to review the following change. 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 --- M src/openvpn/ssl.c 1 file changed, 3 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1297/1 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 567560f..dfbbbc6 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -180,21 +180,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; @@ -227,10 +222,6 @@ return overhead; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void init_ssl_lib(void) { @@ -2651,7 +2642,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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I71e9d4a61d37483685723c16e98f59755694cadf Gerrit-Change-Number: 1297 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --xRLGa9I4yrA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

ssl: change return type of calc_control_cha=
nnel_frame_overhead to size_t

This avoids dealing with conversion wa= rnings inside
the function. Since we only add values that are
suppose= d to be positive this should be safe.

Note that we now cast the retu= rn value to int at
the caller side. There we actually substract it andwant to catch the case where the result gets negative.
Since all the i= nvolved values are quite small compared
to INT_MAX I decided to just cas= t it without further
checks.

Change-Id: I71e9d4a61d37483685723c16= e98f59755694cadf
Signed-off-by: Frank Lichtenheld <frank@...2641...&g= t;
---
M src/openvpn/ssl.c
1 file changed, 3 insertions(+), 12 del= etions(-)

git pull ssh://gerrit.openvpn.net:2941=
8/openvpn refs/changes/97/1297/1
diff --git a/src/openvpn/ssl.c b/s=
rc/openvpn/ssl.c
index 567560f..dfbbbc6 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c<= br>@@ -180,21 +180,16 @@
frame->tun_mtu =3D m= ax_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_cont= rol_channel_frame_overhead(const struct tls_session *session)
{

const struct key_state *ks =3D &session->= key[KS_PRIMARY];
- i= nt overhead =3D 0;
+ = size_t overhead =3D 0;

/* opcode = */
overhead +=3D 1;
@@ -227,10 +222,6 = @@
return overhead;
}

-#if defined(__GNUC_= _) || defined(__clang__)
-#endif
-=
void
init_ssl_lib(void)
{
@@ -2651,7 +2642,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_f= rame_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 change 1297. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I71e9d4a61d37483685723c16e98= f59755694cadf
Gerrit-Change-Number: 1297
Gerrit-PatchSet: 1
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...>
= --xRLGa9I4yrA=--