From: "cron2 (Code Review)" Date: Sun, 16 Nov 2025 22:06:50 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="5IHmNOA3RJ0="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: ssl: Clean up type handling in write_string() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --5IHmNOA3RJ0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#7) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2, Code-Review+2 by plaisthos Change subject: ssl: Clean up type handling in write_string() ...................................................................... ssl: Clean up type handling in write_string() Make better checks for the maxlen input value. Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1300 Message-Id: <20251104091940.10826-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 191.html Signed-off-by: Gert Doering --- M src/openvpn/ssl.c 1 file changed, 9 insertions(+), 8 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/00/1300/7 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 92a68d0..22a1f52 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -1780,20 +1780,16 @@ return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static bool write_string(struct buffer *buf, const char *str, const int maxlen) { - const int len =3D strlen(str) + 1; - if (len < 1 || (maxlen >=3D 0 && len > maxlen)) + const size_t len =3D strlen(str) + 1; + const size_t real_maxlen =3D (maxlen >=3D 0 && maxlen <=3D UINT16_MAX)= ? (size_t)maxlen : UINT16_MAX; + if (len > real_maxlen) { return false; } - if (!buf_write_u16(buf, len)) + if (!buf_write_u16(buf, (uint16_t)len)) { return false; } @@ -1833,6 +1829,11 @@ return len; } =20 +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + static char * read_string_alloc(struct buffer *buf) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?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: I3309265edf8d6bea7bd73b21eef589a92ede6e0a Gerrit-Change-Number: 1300 Gerrit-PatchSet: 7 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --5IHmNOA3RJ0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

View Change

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

ssl: Cl=
ean up type handling in write_string()

Make better checks for the ma= xlen input value.

Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e= 0a
Signed-off-by: Frank Lichtenheld <frank@...2641...>
Acked-by= : Gert Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvp= n.net/c/openvpn/+/1300
Message-Id: <20251104091940.10826-1-gert@...1711...= 96...>
URL: https://www.mail-archive.com/openvpn-devel@...1357...= rge.net/msg34191.html
Signed-off-by: Gert Doering <gert@...1296...>= ;
---
M src/openvpn/ssl.c
1 file changed, 9 insertions(+), 8 delet= ions(-)

git pull ssh://gerrit.openvpn.net:29418/=
openvpn refs/changes/00/1300/7
diff --git a/src/openvpn/ssl.c b/src=
/openvpn/ssl.c
index 92a68d0..22a1f52 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c@@ -1780,20 +1780,16 @@
return true;
= }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcon= version"
-#endif
-
stati= c bool
write_string(struct buffer *buf, const char *str, c= onst int maxlen)
{
- const int len =3D strlen(str) + 1;
- if (len < 1 || (maxlen >=3D 0 &am= p;& len > maxlen))
+ const size_t len =3D strlen(str) + 1;
+ const size_t real_maxlen =3D (maxlen >= =3D 0 && maxlen <=3D UINT16_MAX) ? (size_t)maxlen : UINT16_MAX;<= /span>
+ if (len > rea= l_maxlen)
{
return false;
}
- = if (!buf_write_u16(buf, len))
+ if (!buf_write_u16(buf, (uint16_t)len))
= {
return false;
}@@ -1833,6 +1829,11 @@
return len;
}


+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-= Wconversion"
+#e= ndif
+
static char *

read_string_alloc(struct buffer *buf)
{

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef= 589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --5IHmNOA3RJ0=--