From: "flichtenheld (Code Review)"
Date: Tue, 3 Mar 2026 13:27:44 +0000
In-Reply-To:
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net
Message-ID: <5b9e54d8b16ee1d328c11661a84c8846cb78245a-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="fA4hj6z4Ixs="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: buffer: Clarify
usage of char_class
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: plaisthos
Cc: openvpn-devel
--fA4hj6z4Ixs=
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/+/1142?usp=3Demail
to look at the new patch set (#6).
Change subject: buffer: Clarify usage of char_class
......................................................................
buffer: Clarify usage of char_class
Silence compiler warnings due to conversion from
char to unsigned char. In this case we actually
depend on this conversion.
Change-Id: I73bc163d48b2d6a954cd231961826f33143fcd12
Signed-off-by: Frank Lichtenheld
---
M src/openvpn/buffer.c
1 file changed, 15 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/1142/6
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
index 26f18dd..f10e7c2 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -545,6 +545,10 @@
buf_write_u8(buf, 0);
}
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
/*
* Remove trailing \r and \n chars and ensure
* null termination.
@@ -559,7 +563,7 @@
{
break;
}
- if (char_class(*last, CC_CRLF | CC_NULL))
+ if (char_class((unsigned char)*last, CC_CRLF | CC_NULL))
{
if (!buf_inc_len(buf, -1))
{
@@ -876,6 +880,14 @@
* Classify and mutate strings based on character types.
*/
+/* Note 1: This functions depends on getting an unsigned
+ char. Both the is*() functions and our own checks expect it
+ this way.
+ Note 2: For CC_PRINT we just accept everything >=3D 32, so
+ if we ingest non-ASCII UTF-8 we will classify it as
+ printable since it will be >=3D 128. Other encodings are
+ not officially supported.
+*/
bool
char_class(const unsigned char c, const unsigned int flags)
{
@@ -1019,7 +1031,8 @@
static inline bool
char_inc_exc(const char c, const unsigned int inclusive, const unsigned in=
t exclusive)
{
- return char_class(c, inclusive) && !char_class(c, exclusive);
+ return char_class((unsigned char)c, inclusive)
+ && !char_class((unsigned char)c, exclusive);
}
bool
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1142?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: I73bc163d48b2d6a954cd231961826f33143fcd12
Gerrit-Change-Number: 1142
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
--fA4hj6z4Ixs=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is cur=
rently required from: plaisthos.
flichtenheld uploaded patch set #6 to this change.
<=
p>View C=
hange
buffer: Clarify usage of char_class
Silen=
ce compiler warnings due to conversion from
char to unsigned char. In th=
is case we actually
depend on this conversion.
Change-Id: I73bc16=
3d48b2d6a954cd231961826f33143fcd12
Signed-off-by: Frank Lichtenheld <=
frank@...2641...>
---
M src/openvpn/buffer.c
1 file changed, 15=
insertions(+), 2 deletions(-)
git pull ssh://ge=
rrit.openvpn.net:29418/openvpn refs/changes/42/1142/6
diff --git a/=
src/openvpn/buffer.c b/src/openvpn/buffer.c
index 26f18dd..=
f10e7c2 100644
--- a/src/openvpn/buffer.c
+=
++ b/src/openvpn/buffer.c
@@ -545,6 +545,10 @@
buf_write_u8(buf, 0);
}
<=
br>+#if defined(__GNUC__) || de=
fined(__clang__)
+#pr=
agma GCC diagnostic pop
+#endif
+ /*
* Remove trailing \r and \n chars and ensure<=
/span>
* null termination.
@@ -559,7 +563,7 @@=
span>
{
break;
}
- =
if (char_class(*last, CC_CRLF | CC_NULL))
+ if (char_class((unsigned char)*last, CC_CRLF =
| CC_NULL))
{
if (!bu=
f_inc_len(buf, -1))
{
@@ -876,=
6 +880,14 @@
* Classify and mutate strings based on chara=
cter types.
*/
+/* Note 1: This functions depends on getting=
an unsigned
+ char=
. Both the is*() functions and our own checks expect it
+ this way.
+ Note 2: For CC_PRINT we just accept everyth=
ing >=3D 32, so
+ =
if we ingest non-ASCII UTF-8 we will classify it as
+ printable since it will be >=3D 128=
. Other encodings are
+ not officially supported.
+*/
bool
char_class(const unsig=
ned char c, const unsigned int flags)
{
@@=
-1019,7 +1031,8 @@
static inline bool
ch=
ar_inc_exc(const char c, const unsigned int inclusive, const unsigned int e=
xclusive)
{
- return char_class(c, inclusive) && !char_class(c, exclus=
ive);
+ return cha=
r_class((unsigned char)c, inclusive)
+ && !char_class((unsigned char)c, exclus=
ive);
}
bool
=
To view, visit change 1142. To unsubscribe, or for he=
lp writing mail filters, visit settings.
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73bc163d48b2d6a954cd2319618=
26f33143fcd12
Gerrit-Change-Number: 1142
Gerrit-PatchSet: 6
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...>
=
--fA4hj6z4Ixs=--