From: "flichtenheld (Code Review)" Date: Tue, 3 Mar 2026 14:07:55 +0000 In-Reply-To: References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Q1FUgm2T0pM="; 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 --Q1FUgm2T0pM= 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 (#7). 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, 11 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/1142/7 diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index dd74b38..12a8ff9 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -559,7 +559,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 +876,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 +1027,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: 7 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --Q1FUgm2T0pM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld uploaded patch set #7 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, 11= insertions(+), 2 deletions(-)

git pull ssh://ge=
rrit.openvpn.net:29418/openvpn refs/changes/42/1142/7
diff --git a/=
src/openvpn/buffer.c b/src/openvpn/buffer.c
index dd74b38..= 12a8ff9 100644
--- a/src/openvpn/buffer.c
+= ++ b/src/openvpn/buffer.c
@@ -559,7 +559,7 @@
{
break;
= }
- if (char_cla= ss(*last, CC_CRLF | CC_NULL))
+ if (char_class((unsigned char)*last, CC_CRLF | CC_NULL))<= /span>
{
if (!buf_inc_len(bu= f, -1))
{
@@ -876,6 +876,14 @@=
* Classify and mutate strings based on character types.<= /span>
*/

+/* Note 1: This functions depends on getting an unsigned=
+ char. Both the i= s*() functions and our own checks expect it
+ this way.
+ Note 2: For CC_PRINT we just accept everything >=3D = 32, so
+ if we inge= st non-ASCII UTF-8 we will classify it as
+ printable since it will be >=3D 128. Other enco= dings are
+ not off= icially supported.
+*= /
bool
char_class(const unsigned char c, = const unsigned int flags)
{
@@ -1019,7 +10= 27,8 @@
static inline bool
char_inc_exc(c= onst char c, const unsigned int inclusive, const unsigned int exclusive)
{
- r= eturn char_class(c, inclusive) && !char_class(c, exclusive);=
+ return char_class((uns= igned char)c, inclusive)
+ && !char_class((unsigned char)c, exclusive);=
}

bool

To view, visit change 1142. To unsubscribe, or for help writing m= ail filters, visit settings.

<= /div>
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73bc163d48b2d6a954cd2319618= 26f33143fcd12
Gerrit-Change-Number: 1142
Gerrit-PatchSet: 7
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...>
= --Q1FUgm2T0pM=--