From: "flichtenheld (Code Review)"
Date: Tue, 11 Nov 2025 14:26:54 +0000
In-Reply-To:
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net, gert@...1296...
Message-ID: <87eaf1f820572f81e7b792dd4722111f72e1c111-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="KWHo23bZ5qs="; 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: plaisthos
Cc: openvpn-devel
--KWHo23bZ5qs=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1300?usp=3Demail
to look at the new patch set (#6).
The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied=
now.
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
---
M src/openvpn/ssl.c
1 file changed, 9 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/00/1300/6
diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index 355ab46..86f6f59 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;
}
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
static char *
read_string_alloc(struct buffer *buf)
{
--=20
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: 6
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: cron2
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: flichtenheld
--KWHo23bZ5qs=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is cur=
rently required from: flichtenheld.
flichtenheld uploaded patch set #6 to this change.
<=
p>View C=
hange
The change is no longer submittable: checks~ChecksSubmitRul=
e is unsatisfied now.
ssl: Clean up type handling in write=
_string()
Make better checks for the maxlen input value.
Chan=
ge-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Signed-off-by: Frank Li=
chtenheld <frank@...2641...>
---
M src/openvpn/ssl.c
1 file =
changed, 9 insertions(+), 8 deletions(-)
git pul=
l ssh://gerrit.openvpn.net:29418/openvpn refs/changes/00/1300/6
dif=
f --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index 355ab=
46..86f6f59 100644
--- a/src/openvpn/ssl.c
=
+++ b/src/openvpn/ssl.c
@@ -1780,20 +1780,16 @@
<=
span> return true;
}
-#if defined(__GNUC__) || defined(__cl=
ang__)
-#pragma GCC dia=
gnostic push
-#pragma G=
CC diagnostic ignored "-Wconversion"
-#endif
-
static bool
write_string(struc=
t 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, (uint=
16_t)len))
{
return false;
}
@@ -1833,6 +1829,11 @@
return len;
}
+#if defined(__GNUC__) || defined(__clang=
__)
+#pragma GCC diag=
nostic push
+#pragma =
GCC diagnostic ignored "-Wconversion"
+#endif
+
static char *
read_string=
_alloc(struct buffer *buf)
{
=
pre>To view, visit change 1300. To unsubscribe, or for help writing mail fil=
ters, visit sett=
ings.
<=
link itemprop=3D"url" href=3D"http://gerrit.openvpn.net/c/openvpn/+/1300?us=
p=3Demail"/>
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef=
589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 6
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>
Gerrit-Attention: flichtenheld <frank@...2375...=
41...>
=
--KWHo23bZ5qs=--